This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Math | |
def self.factorial(f) | |
f == 0 ? 1 : f * factorial(f - 1) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |