ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> ruby-talk
ruby-talk
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

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved