Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

37 lines (32 sloc) 0.592 kb
################################################################################
# 1.8_bigger_smaller.rb
#
# * if-else
# * while
# * times
################################################################################
# if
a = 20
if a >= 10 then # you can skip "then"
print("bigger\n")
end
if a <= 9 then
print("smaller\n")
end
# if-else
if a >= 10
print("bigger\n")
else
print("smaller\n")
end
# while
i = 1
while i <= 10
print(i, "\n")
i = i + 1
end
# times
# times method is a method called "iterator"
10.times {
print "All work and no play makes Jack a dull boy.\n"
}
Jump to Line
Something went wrong with that request. Please try again.