Created
September 13, 2015 10:58
-
-
Save tsevdos/5156671a5240929bfa4e to your computer and use it in GitHub Desktop.
Ruby tips : Parallel Assignment of Variables
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
a, b, c = 50, 'cent', :test | |
# a => 50 | |
# b => 'cent' | |
# c => :test |
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 return_stuff | |
return 50, 'cent', :test | |
end | |
a, b, c = return_stuff | |
# a => 50 | |
# b => 'cent' | |
# c => :test |
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 strong_and_weak | |
return @players.select{|player| player.strong? }, @players.select{|player| !player.strong? } | |
end | |
strong_players, weak_players = strong_and_weak |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment