-
-
Save stevegraham/3753194 to your computer and use it in GitHub Desktop.
splat
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
| hash = { :name=>"Steve Graham", :age=>24 } | |
| # => { :name=>"Steve Graham", :age=>24 } | |
| array = *hash | |
| # => [[:name, "Steve Graham"], [:age, 24]] |
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
| wow = Hash[array] | |
| # => { :name=>"Steve Graham", :age=>24 } |
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
| males = %w(pharrell chad shae) | |
| females = %w(cameron jessica alyssa) | |
| justin_timberlake = case gender | |
| when *females "ladies good morning" | |
| when *males "gentlemen goodnite" | |
| when *males|females "hahahahaha and that's it" | |
| end |
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
| lines = *File.open('/etc/hosts') |
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
| %w(a list of arbitrary words) * ", " | |
| # => "a, list, of, arbitrary, words" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment