Skip to content

Instantly share code, notes, and snippets.

@wuputah
Created January 20, 2009 20:20
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 wuputah/49647 to your computer and use it in GitHub Desktop.
Save wuputah/49647 to your computer and use it in GitHub Desktop.
# this works fine, but it uses a local variable with no purpose
factorial = lambda do |n|
return 1 if n <= 1
n * factorial.call(n - 1)
end
puts factorial.call(5)
puts lambda do |n|
return 1 if n <= 1
n * SELF.call(n - 1)
end.call(5)
# what do you use for 'SELF' that actually works?
# or, is there an another way to do this (while still using anonymous functions)?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment