Skip to content

Instantly share code, notes, and snippets.

module Math
def self.factorial(f)
f == 0 ? 1 : f * factorial(f - 1)
end
end
# Or we can extend an instance of Fixnum so we can do 5.factorial :)
class Fixnum
def factorial
self == 0 ? 1 : self * (self - 1).factorial
module Math
def self.factorial(f)
f == 0 ? 1 : f * factorial(f - 1)
end
end
Ruby Wins
by James CF
C#m G#m F#m A
Use a block to print your name,
Use equality to test the same,
Blocks and lambdas you can call,
Private methods, send from all.