# Using String#slice with a symbol argument

**URL:** <https://www.ruby-forum.com/t/using-string-slice-with-a-symbol-argument/117286>\
**Category:** Ruby\
**Created:** [October 15, 2007, 5:41pm UTC](https://www.ruby-forum.com/t/using-string-slice-with-a-symbol-argument/117286 "2007-10-15T17:41:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mdemare](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/bbe5ce/32.png) [@mdemare](https://www.ruby-forum.com/u/mdemare)\
**Post date:** [October 15, 2007, 5:41pm UTC](https://www.ruby-forum.com/t/using-string-slice-with-a-symbol-argument/117286/1 "2007-10-15T17:41:00Z")

</div>

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?
