Skip to content

Instantly share code, notes, and snippets.

@parasquid
Last active February 18, 2020 07:54
Show Gist options
  • Save parasquid/775d2ba7518600afc747bb91aa097b16 to your computer and use it in GitHub Desktop.
Save parasquid/775d2ba7518600afc747bb91aa097b16 to your computer and use it in GitHub Desktop.
shortcircuit returning a value in a block
array = (1..100).map do |num|
return "fizzbuzz" if num % 3 == 0 && num % 5 == 0
return "fizz" if num % 3 == 0
return "buzz" if num % 5 == 0
num
end
puts array
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment