Created
July 20, 2012 21:02
-
-
Save davidcelis/3153192 to your computer and use it in GitHub Desktop.
How to refer to other elements in the same hash
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
hash = { | |
:before => "Hello", | |
:after => "world!", | |
:ref => lambda { hash[:before] << ' ' << hash[:after] } | |
} | |
hash[:ref].call # => "Hello world!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment