newbie: functions don't work in script

C

Christoph Klocker

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

PWR

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

Peter.
 
H

Hannes Wyss

Christoph,

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

try this:

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

Christoph Klocker

PWR said:
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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top