you can always do something like!!(/[AEIOU]/i =~ self) That will return true or false --- Met vriendelijke groeten - Best regards - Salutations Ivan Porto Carrero Blog: http://flanders.co.nz Twitter: http://twitter.com/casualjim Author of IronRuby in Action (http://manning.com/carrero)
On Fri, Jul 10, 2009 at 5:54 PM, <[email protected]> wrote: > > Agreed, only nil and false are false. > > In my scenario, I take the result of the Ruby function and feed it back to > C#. Here's where it is nice to have either an instance of the TrueClass or > FalseClass; otherwise, I need to teach my C# application the Ruby rules for > converting an integer to a Boolean, or I need to convert the integer to a > Boolean in Ruby. > > -- Chuck > > -- > Chuck Durfee > Sr. Internet Software Developer > TSYS iSolutions, Golden > Email [email protected] > > > > *"Pete Bacon Darwin" <[email protected]>* > Sent by: [email protected] > > 07/10/2009 09:40 AM > Please respond to > [email protected] > > To > <[email protected]> cc > Subject > Re: [Ironruby-core] Use of case operator > > > > > That’s OK because in Ruby 0 is true! (Only nil and false are false) > > *From:* [email protected] [mailto: > [email protected]] *On Behalf Of *[email protected]* > Sent:* 10 July 2009 16:21* > To:* [email protected]* > Cc:* [email protected]; [email protected]* > Subject:* Re: [Ironruby-core] Use of case operator > > > Sorry, yes, I know about the =~ operator, but I believe that returns an > integer (the position of the first match) or nil, not a Boolean as I > require. > > -- Chuck > > -- > Chuck Durfee > Sr. Internet Software Developer > TSYS iSolutions, Golden > Email [email protected] > > *Kibiz0r <[email protected]>* > Sent by: [email protected] > > 07/10/2009 09:07 AM > > > Please respond to > [email protected] > > > To > [email protected] cc > Subject > Re: [Ironruby-core] Use of case operator > > > > > > > > > Chuck, > > Yes, there's an operator just for this scenario! > > The regular expression operator: =~ > > Mike > > On Fri, Jul 10, 2009 at 10:34 AM, <*[email protected]* <[email protected]>> > wrote: > > I'm fairly new to Ruby, and I have a usage question. > > There are times when I want to know if a regular expression matches a given > input. For example: > > class String > def containsVowel? > /[AEIOU]/i === self > end > end > > Is there a common Ruby idiom for this, or is using the case operator this > way the norm? > > -- Chuck > > -- > Chuck Durfee > Sr. Internet Software Developer > TSYS iSolutions, Golden > Email *[email protected]* <[email protected]> > ------------------------------ > > *The information contained in this communication (including any > attachments hereto) is confidential and is intended solely for the personal > and confidential use of the individual or entity to whom it is addressed. If > the reader of this message is not the intended recipient or an agent > responsible for delivering it to the intended recipient, you are hereby > notified that you have received this communication in error and that any > review, dissemination, copying, or unauthorized use of this information, or > the taking of any action in reliance on the contents of this information is > strictly prohibited. If you have received this communication in error, > please notify us immediately by e-mail, and delete the original message. > Thank you * > > > _______________________________________________ > Ironruby-core mailing list* > **[email protected]* <[email protected]>* > **http://rubyforge.org/mailman/listinfo/ironruby-core*<http://rubyforge.org/mailman/listinfo/ironruby-core> > > > > > -- > Michael Harrington | Software Apprentice > Atomic Object | *http://atomicobject.com* <http://atomicobject.com/> > [Ph] +1 616 776 6020 [Fx] +1 616 776 6015 > _______________________________________________ > Ironruby-core mailing list > [email protected] > http://rubyforge.org/mailman/listinfo/ironruby-core > ------------------------------ > > *The information contained in this communication (including any > attachments hereto) is confidential and is intended solely for the personal > and confidential use of the individual or entity to whom it is addressed. If > the reader of this message is not the intended recipient or an agent > responsible for delivering it to the intended recipient, you are hereby > notified that you have received this communication in error and that any > review, dissemination, copying, or unauthorized use of this information, or > the taking of any action in reliance on the contents of this information is > strictly prohibited. If you have received this communication in error, > please notify us immediately by e-mail, and delete the original message. > Thank you * > > Checked by AVG - www.avg.com > Version: 8.5.375 / Virus Database: 270.13.5/2220 - Release Date: 07/09/09 > 18:07:00_______________________________________________ > Ironruby-core mailing list > [email protected] > http://rubyforge.org/mailman/listinfo/ironruby-core > > ------------------------------ > > * The information contained in this communication (including any > attachments hereto) is confidential and is intended solely for the personal > and confidential use of the individual or entity to whom it is addressed. If > the reader of this message is not the intended recipient or an agent > responsible for delivering it to the intended recipient, you are hereby > notified that you have received this communication in error and that any > review, dissemination, copying, or unauthorized use of this information, or > the taking of any action in reliance on the contents of this information is > strictly prohibited. If you have received this communication in error, > please notify us immediately by e-mail, and delete the original message. > Thank you * > > > _______________________________________________ > Ironruby-core mailing list > [email protected] > http://rubyforge.org/mailman/listinfo/ironruby-core > >
_______________________________________________ Ironruby-core mailing list [email protected] http://rubyforge.org/mailman/listinfo/ironruby-core
