ARGV question

J

Joe Johnson

I don't understand why since ARGV (the global command line argument
array) doesn't have the $ at the front as $ARGV since it's a global
variable? This looks inconsistent to me since Ruby requires all global
variables to begin with $. Can anyone please clarify this? TIA.
 
G

gabriele renzi

il Sun, 19 Oct 2003 08:29:07 -0700, Joe Johnson
I don't understand why since ARGV (the global command line argument
array) doesn't have the $ at the front as $ARGV since it's a global
variable? This looks inconsistent to me since Ruby requires all global
variables to begin with $. Can anyone please clarify this? TIA.

It is a constant, not a variable.
 
R

Robert Klemme

Joe Johnson said:
I don't understand why since ARGV (the global command line argument
array) doesn't have the $ at the front as $ARGV since it's a global
variable? This looks inconsistent to me since Ruby requires all global
variables to begin with $. Can anyone please clarify this? TIA.

I think, it's a constant in class Object and thus inherited by all objects.
Since you're always in the context of *some* instance you always can access
ARGV unqualified, i.e., use "ARGV" instead of "Object::ARGV".
?> Object::ARGV
=> []?> Foo.new.arg
=> "XXX"SyntaxError: compile error
(irb):24: syntax error
from (irb):24
Regards

robert
 

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
474,138
Messages
2,570,804
Members
47,349
Latest member
jojonoy597

Latest Threads

Top