For Programmers: Free Programming Magazines  


Home > Archive > Ruby > August 2005 > Re: symbols vs. strings









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: symbols vs. strings
Brian Schröder

2005-08-28, 6:59 pm

On 26/08/05, Mark Volkmann <r.mark.volkmann@gmail.com> wrote:
> On 8/26/05, Brian Schr=F6der <ruby.brian@gmail.com> wrote:
n the Hash.[color=darkred]
n[color=darkred]
>=20
>=20
> Just to clarify, are you saying that ...
>=20
> 1) If I want my code that accepts a Hash parameter to allow keys to be
> either Symbols or Strings, I need to use an approach like you showed
> above.
>=20
> 2) Many existing Ruby classes do this.


Yes, that is two times true. Hashes do not special-case for strings or
symbols. (Nearly) anything can go into a Hash as keys. Generally ruby
does not special case very often. Thats what makes it so nice to learn
and use.

regards,

Brian

>=20
> --
> R. Mark Volkmann
> Partner, Object Computing, Inc.
>=20
>=20



--=20
http://ruby.brian-schroeder.de/

Stringed instrument chords: http://chordlist.brian-schroeder.de/


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com