[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

New to Ruby from CF

Ben V.

7/20/2006 10:19:00 PM

I'm new to Ruby and Rails from Coldfusion, and I am already finding how
much easier Ruby programming is, yet one thing that I haven't quite
figured out how to do in Ruby is to test whether for example, a contains
b. In Coldfusion we did <cfif a CONTAINS b>, but I can't seem to find a
CONTAINS() function or operator in Ruby. What would be the Ruby
equivalent of the code above? And How would I test if one var contains
another, or another string? Thanks for your help and time.

--
Posted via http://www.ruby-....

3 Answers

Phillip Hutchings

7/20/2006 10:23:00 PM

0

On 7/21/06, Ben V. <comprug@gmail.com> wrote:
> I'm new to Ruby and Rails from Coldfusion, and I am already finding how
> much easier Ruby programming is, yet one thing that I haven't quite
> figured out how to do in Ruby is to test whether for example, a contains
> b. In Coldfusion we did <cfif a CONTAINS b>, but I can't seem to find a
> CONTAINS() function or operator in Ruby. What would be the Ruby
> equivalent of the code above? And How would I test if one var contains
> another, or another string? Thanks for your help and time.

if a.include? b

Check the documentation for Array and Hash.


--
Phillip Hutchings
http://www.sit...

Justin Collins

7/20/2006 10:35:00 PM

0

Phillip Hutchings wrote:
> On 7/21/06, Ben V. <comprug@gmail.com> wrote:
>> I'm new to Ruby and Rails from Coldfusion, and I am already finding how
>> much easier Ruby programming is, yet one thing that I haven't quite
>> figured out how to do in Ruby is to test whether for example, a contains
>> b. In Coldfusion we did <cfif a CONTAINS b>, but I can't seem to find a
>> CONTAINS() function or operator in Ruby. What would be the Ruby
>> equivalent of the code above? And How would I test if one var contains
>> another, or another string? Thanks for your help and time.
>
> if a.include? b
>
> Check the documentation for Array and Hash.
>
>
Also works for strings, if that's what you meant. (Don't know Coldfusion).

-Justin

Ben V.

7/20/2006 11:16:00 PM

0

Thanks, sorry for the stupid question, but hopefully I'll get the hang
of Ruby. You would consider CF as a relatively easy language, but it's
nothing like Ruby.

--
Posted via http://www.ruby-....