using String#slice with a symbol argument.

M

Michiel de Mare

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,045
Latest member
DRCM

Latest Threads

Top