tags:

views:

66

answers:

2

Hello,

I was wondering the right usage for global variable $*.

If the program has puts $*[0] it works great. On the contrary, if I use it as follows:

   for i in 2..$*[0] 

a bad value for range (ArgumentError) is throw. Any advise is appreciated

A: 

ehm why would u use it ? if i am correct you could do this:

$hello = "Hello world"

it will work fine. you can use it for example if you have something like this:

$hello = "hello world"
class test
   def putHello()
    puts $hello
   end
end
t = test.new
how does this relate to ARGV
Maddy
ohw I am sorry. I thought it was a question about the $ type and when to use it. my mistake
+1  A: 

That's because it has the wrong type. Try this:

for i in 2..$*[0].to_i
Olivier
Great. I'm learning ruby. I thought it would be cast to the right type like perl.
Maddy