Skip to content

Instantly share code, notes, and snippets.

@mindplace
Last active March 23, 2016 16:15
Show Gist options
  • Select an option

  • Save mindplace/91e97e4a8f20c6227ae4 to your computer and use it in GitHub Desktop.

Select an option

Save mindplace/91e97e4a8f20c6227ae4 to your computer and use it in GitHub Desktop.
def inconsistent_adder_with_enumerable(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 [num1, num2].inject{|sum, num| sum + num}
else
puts "\nTails! Take your stupid numbers back!"
puts "#{[num1, num2]}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment