[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

newbie: functions don't work in script

Christoph Klocker

1/12/2006 1:43:00 PM

sorry for this newbie question, just started ruby programming today,

Try to work me through the book Programming Ruby

the script:

#!/usr/local/bin/ruby
a = [ "a", "b", "c" ]
a.include?("b")

returns me nothing,
if I do the same in "irb"
it returns "true"

why does it not work in the shell script??

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


3 Answers

PWR

1/12/2006 2:01:00 PM

0

Try changing the last line of your script to,
puts a.include?("b")
irb automatically prints out the evaluation of an expression.

Peter.

Hannes Wyss

1/12/2006 2:03:00 PM

0

Christoph,

your script doesn't do anything with the return-value of 'include?'

try this:

#!/usr/local/bin/ruby
a = [ "a", "b", "c" ]
p a.include?("b")


Christoph Klocker

1/12/2006 2:14:00 PM

0

PWR wrote:
> Try changing the last line of your script to,
> puts a.include?("b")
> irb automatically prints out the evaluation of an expression.
>
> Peter.

thx a lot, now I got it!

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