Newbie: functions don't work in script

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

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

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!

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

Peter.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs