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
irb(main):001:> why_are_we_here = -> (x) { puts x } | |
irb(main):002:> why_are_we_here.call("It's worth it.") | |
It\'s worth it. | |
=> nil | |
irb(main):003:> why_are_we_here = -> (x) { why_are_we_here(x) } | |
irb(main):004:> why_are_we_here.call(nil) | |
Traceback (most recent call last): | |
5: from /usr/bin/irb:23:in `<main>' | |
4: from /usr/bin/irb:23:in `load' |
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
def countdown(n) | |
return if n.zero? # base case | |
puts n | |
countdown(n-1) # getting closer to base case | |
end | |
countdown(5) # => output: 5 4 3 2 1 |
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
class CharlieBlog extends Blog { | |
public function hi() { | |
return "Hello, world!"; | |
} | |
} |
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
100.times do | |
puts "Hello, world!".red | |
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
class Test < BaseTest | |
def hi | |
"hi" | |
end | |
end | |
class Test < BaseTest | |
def hi | |
"hi" | |
end |