Skip to content

Instantly share code, notes, and snippets.

@tsevdos
Created September 13, 2015 10:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsevdos/5156671a5240929bfa4e to your computer and use it in GitHub Desktop.
Save tsevdos/5156671a5240929bfa4e to your computer and use it in GitHub Desktop.
Ruby tips : Parallel Assignment of Variables
a, b, c = 50, 'cent', :test
# a => 50
# b => 'cent'
# c => :test
def return_stuff
return 50, 'cent', :test
end
a, b, c = return_stuff
# a => 50
# b => 'cent'
# c => :test
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