Created
February 1, 2014 19:46
-
-
Save stujo/8757665 to your computer and use it in GitHub Desktop.
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
#Using Symbols as keys | |
customer = { | |
name: "Billy Bob", | |
tel: "(415)555-5555", | |
} | |
customer['name'] | |
customer.keys.each do |key| puts key.object_id end | |
customer.delete_if {| key, value | :tel == key } | |
hsh.compare_by_identity Use object ids instead of equality for lookups | |
hsh.default Returns the default value that would be used | |
hsh.default= Sets the default value | |
hsh.default_proc Returns the proc to be executed on failing lookup | |
hsh.default_proc= Assigns a default proc | |
hsh.default_proc= proc do |hash,key| "default for #{key}" end | |
delete(key) {| key | block } → value | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment