Last active
February 18, 2020 07:54
-
-
Save parasquid/775d2ba7518600afc747bb91aa097b16 to your computer and use it in GitHub Desktop.
shortcircuit returning a value in a block
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
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