Skip to content

Instantly share code, notes, and snippets.

@memetor
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save memetor/f9b69a3ffbe8968f8ee6 to your computer and use it in GitHub Desktop.
Save memetor/f9b69a3ffbe8968f8ee6 to your computer and use it in GitHub Desktop.
# cf. http://www.slideshare.net/esehara/for-38276816
# 1
i = 1
while i <= 10 do
puts i
i += 1
end
# 2
(1..10).each(&method(:puts))
# 3
def r(n = 1)
puts n
r(n + 1) unless n == 10
end
r
# 4
class Fixnum
def r
puts self
(self + 1).r unless self == 10
end
end
1.r
# 5
puts 1
puts 2
puts 3
puts 4
puts 5
puts 6
puts 7
puts 8
puts 9
puts 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment