[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

using String#slice with a symbol argument.

Michiel de Mare

10/15/2007 3:36:00 PM

Currently, ruby 1.8.6. has the following behavior:

'ruby'[:en] #=> nil

The reason is that the symbol is converted to an integer using
to_int. But this is never useful, and can be a source of obscure bugs
when your variable contains a string instead of an hash.

Wouldn't raising an exception be more appropriate?