Skip to content

Instantly share code, notes, and snippets.

@martinpovolny
Created February 27, 2014 16:51
Show Gist options
  • Save martinpovolny/9254114 to your computer and use it in GitHub Desktop.
Save martinpovolny/9254114 to your computer and use it in GitHub Desktop.
why don't we have .to_sym_if_exists in ruby? same as erlang has? http://www.erlang.org/doc/man/erlang.html#binary_to_existing_atom-2
iex(3)> :erlang.binary_to_existing_atom("foobar", :utf8)
** (ArgumentError) argument error
:erlang.binary_to_existing_atom("foobar", :utf8)
iex(3)> :foobar
:foobar
iex(4)> :erlang.binary_to_existing_atom("foobar", :utf8)
:foobar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment