M
Mayuresh Kathe
Hi,
There's one more thing, I also read the following statements;
---
Ruby's hashes can use any object as a key, but Symbol objects are the
most commonly
used. Symbols are immutable, interned strings. They can be compared by identity
rather than by textual content (because two distinct Symbol objects
will never have the
same content).
---
The statement, "because two distinct Symbol objects will never have
the same content" seems unclear to me.
Can't I do the following?
books = {
:excellent => "Iacocca",
:good => "Freakonomics",
:bad => "The World is Flat",
:ugly => "Guns, Germs and Steel",
:sick => "Guns, Germs and Steel"
}
In that case, won't two distinct Symbol objects, i.e. :ugly, and :sick
have the same content?
I'm sure there's something wrong in the way I'm understanding this,
could someone please elaborate?
Thanks,
~Mayuresh
There's one more thing, I also read the following statements;
---
Ruby's hashes can use any object as a key, but Symbol objects are the
most commonly
used. Symbols are immutable, interned strings. They can be compared by identity
rather than by textual content (because two distinct Symbol objects
will never have the
same content).
---
The statement, "because two distinct Symbol objects will never have
the same content" seems unclear to me.
Can't I do the following?
books = {
:excellent => "Iacocca",
:good => "Freakonomics",
:bad => "The World is Flat",
:ugly => "Guns, Germs and Steel",
:sick => "Guns, Germs and Steel"
}
In that case, won't two distinct Symbol objects, i.e. :ugly, and :sick
have the same content?
I'm sure there's something wrong in the way I'm understanding this,
could someone please elaborate?
Thanks,
~Mayuresh