May 10, 2007 at 2:04 pm · Filed under Ruby Hash
This sample shows how to add element to ruby hash
These icons link to social bookmarking sites where readers can share and discover new web pages.
Permalink
August 10, 2007 @ 12:39 am
Thanks for this example. Though it is simple, I found it useful.
November 16, 2007 @ 8:47 am
Thank you, this is exactly what I was looking for.
January 2, 2008 @ 1:11 am
Hi,
Thanks, for this,
You may also want to mention that if there is a duplicate key in the new hash, it will overwrite the original hash.
So if I did this on the original hash:
users_hash.merge(”tom” => “changed_password”)
It would change the original hash , thus changing tom’s password to be ‘changed_password’.
Hamza
January 3, 2008 @ 8:32 am
users_hash[key] = value
Why not this method?
August 17, 2008 @ 1:24 pm
@Andrei, because that method merges one specific key only while the described method merges hashes of any size together.
RSS feed for comments on this post · TrackBack URI
Name (required)
E-mail required)
URI
Xin said,
August 10, 2007 @ 12:39 am
Thanks for this example. Though it is simple, I found it useful.
Anthony said,
November 16, 2007 @ 8:47 am
Thank you, this is exactly what I was looking for.
Hamza Khan-Cheema said,
January 2, 2008 @ 1:11 am
Hi,
Thanks, for this,
You may also want to mention that if there is a duplicate key in the new hash, it will overwrite the original hash.
So if I did this on the original hash:
users_hash.merge(”tom” => “changed_password”)
It would change the original hash , thus changing tom’s password to be ‘changed_password’.
Hamza
Andrei said,
January 3, 2008 @ 8:32 am
users_hash[key] = value
Why not this method?
Luke said,
August 17, 2008 @ 1:24 pm
@Andrei, because that method merges one specific key only while the described method merges hashes of any size together.