Comparing String with Symbol
by ibc other posts by this author
May 8 2008 7:52AM messages near this date
Re: integers with preceding zero don't return as expected?
|
Re: Comparing String with Symbol
Hi, losts of Ruby methods allow String or Symbol as parameter, for example:
["AAA","BBB"].send('first')
=> "AAA"
["AAA","BBB"].send(:first)
=> "AAA"
If I want to accespt String or Symbol, is there an easy wat to allow
both without doing something explicit as:
if pos == :first || pos == 'first'
Maybe using:
if pos.to_s == 'first'
is the best way?
--
Iñaki Baz Castillo
<ibc@[...].net>
Thread:
ibc
Roger Pack
Simon Krahnke
Evan David Light
Ryan Davis
M. Edward Borasky
Roger Pack
Phillip Gawlowski
Robert Dober
Yukihiro Matsumoto
Roger Pack
ibc
Michael Neumann
Albert Schlef
Michael Neumann
Yukihiro Matsumoto
|