[Ironruby-core] Use of case operator

Ryan Riley ryan.riley at panesofglass.org
Fri Jul 10 12:00:48 EDT 2009


Not sure, but this thread may shed some light:
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/103216.

You could get the result from the =~ operation, then transform using the
.to_bool extension suggested above.


Ryan Riley
ryan.riley at panesofglass.org
http://panesofglass.org/
http://wizardsofsmart.net/


On Fri, Jul 10, 2009 at 10:54 AM, <CDurfee at tsys.com> 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 cdurfee at tsys.com
>
>
>
>  *"Pete Bacon Darwin" <bacondarwin at googlemail.com>*
> Sent by: ironruby-core-bounces at rubyforge.org
>
> 07/10/2009 09:40 AM
>   Please respond to
> ironruby-core at rubyforge.org
>
>   To
> <ironruby-core at rubyforge.org>  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:* ironruby-core-bounces at rubyforge.org [mailto:
> ironruby-core-bounces at rubyforge.org] *On Behalf Of *CDurfee at tsys.com*
> Sent:* 10 July 2009 16:21*
> To:* ironruby-core at rubyforge.org*
> Cc:* ironruby-core at rubyforge.org; ironruby-core-bounces at rubyforge.org*
> 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 cdurfee at tsys.com
>
>   *Kibiz0r <kibiz0r at gmail.com>*
> Sent by: ironruby-core-bounces at rubyforge.org
>
> 07/10/2009 09:07 AM
>
>
>   Please respond to
> ironruby-core at rubyforge.org
>
>
>   To
> ironruby-core at rubyforge.org  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, <*CDurfee at tsys.com* <CDurfee at tsys.com>>
> 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 *cdurfee at tsys.com* <cdurfee at tsys.com>
> ------------------------------
>
> *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*
> **Ironruby-core at rubyforge.org* <Ironruby-core at rubyforge.org>*
> **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
> Ironruby-core at rubyforge.org
> 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
> Ironruby-core at rubyforge.org
> 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
> Ironruby-core at rubyforge.org
> http://rubyforge.org/mailman/listinfo/ironruby-core
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090710/75779b6b/attachment.html>


More information about the Ironruby-core mailing list