Newbie: functions don't work in script


#1

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??


#2

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”)


#3

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!


#4

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

Peter.