You hardly ever have to use the word true in your code.
if (something == true)
# do something cool
endCan be rewritten as
| # 1: Remove all hats. All are 0. | |
| # 2: Every 2nd cat is switched to 1. [0, 1, 0, 1] | |
| # 3: Every 3rd cat is switched (toggled). [0, 1, 1, 1] | |
| # 4: [ 0, 1, 1, 0 ] | |
| max = 100 | |
| cats = Array.new(max, 1) | |
| p cats |
| # Print out a list of actions | |
| def ask_action choices | |
| puts "\n\nWhat do you want to do?" | |
| puts choices | |
| gets.chomp.downcase | |
| end | |
| def print_description(desc) | |
| puts desc.gsub(/(?<=\A|\n)[ ]{2,}/,"") | |
| end |
| def add_two number | |
| return nil unless number.respond_to? :+ | |
| # if number.respond_to? :+ | |
| if number.respond_to? :concat | |
| if number.respond_to? :push | |
| number.push 2 | |
| else | |
| number.concat "2" | |
| end |
| expression = true | |
| while (expression) do | |
| 80.times { puts } | |
| puts "hello" | |
| puts "enter your age:" | |
| answer = gets.chomp | |
| if answer.to_i > 20 | |
| # You're 21 or over |
| # Here we're demoing how puts and p work, | |
| # as well as logging and commenting. | |
| #1.+() | |
| # puts "Hello World" | |
| # p "Hello World!" | |
| # p "Hello World!\n" | |
| puts "This is the Ruby version (puts)" | |
| puts RUBY_VERSION | |
| puts "This is the Ruby version (p)" |
| # Here we're demoing how puts and p work, | |
| # as well as logging and commenting. | |
| #1.+() | |
| # puts "Hello World" | |
| # p "Hello World!" | |
| # p "Hello World!\n" | |
| puts "This is the Ruby version (puts)" | |
| puts RUBY_VERSION | |
| puts "This is the Ruby version (p)" |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>Test</title> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> | |
| </head> | |
| <body> | |
| <p>Bacon ipsum dolor amet landjaeger exercitation ullamco ea t-bone non pork | |
| chop chuck cillum drumstick duis magna brisket laborum pork loin. Consequat | |
| dolor shoulder, ham hock exercitation id velit aliquip dolore spare ribs |
| #!/usr/bin/env ruby | |
| # | |
| # Checks to see if the wirble gem is installed and | |
| # installs it for you if it is not already installed. | |
| def gem_list | |
| @gem_list ||= `gem list` | |
| end | |
| def gem_name_re |
I hereby claim:
To claim this, I am signing this object: