Tags

#
# Control structures: if, while, do
if count > 10
  puts "Try again"
elsif tries == 3
  puts "You lose"
else
  puts "Enter a number"
end

while weight < 100 and num_pallets  3000
distance = distance * 1.2 while distance < 100

#
# Blocks and Iterators
do
  club.enroll(person) # and so is this
  person.socialize #
end

animals = %w( ant bee cat dog elk ) # create an array
animals.each {|animal| puts animal } # iterate over the contents
3.times { print "Ho! " } #=> Ho! Ho! Ho!

Advertisements