Created
March 23, 2016 16:21
-
-
Save mindplace/78071290b85bac699732 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 inconsistent_adder_with_implicit_block(num1, num2) | |
| puts "Let's play a game! Me, the program, will flip a coin." | |
| puts "If it's heads, I'll add up your numbers," | |
| puts "and if tails, I'll throw them back in your face." | |
| puts "Flipping a coin..." | |
| sleep(4) | |
| coin = ["heads", "tails"].sample | |
| if coin == "heads" | |
| puts "\nHeads. Fine, here's your sum..." | |
| puts yield(num1, num2) | |
| else | |
| puts "\nTails! Take your stupid numbers back!" | |
| puts "#{[num1, num2]}" | |
| end | |
| end | |
| inconsistent_adder_with_implicit_block(1, 2) {|x, y| x + y} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment