Issue with uninitialized constant ARG (NameError)

Hi,

I have a really wierd issue going on with command line on windows:

I have 2 files

C:\Data\Projects\Ruby\tests>ruby ParseTest.rb source.csv
source.csv
target.au3

C:\Data\Projects\Ruby\tests>ruby StringTest.rb source.csv
StringTest.rb:12: uninitialized constant ARG (NameError)

ParseTest.rb contains:

Parsing Test - Ruby CB 21.3

#puts ‘This program will output the command line arguments word by word’
#ARGV.each {|line| puts line}
puts ARGV[0]
puts ARGV[1]


StringTest.rb contains:

the first commandline argument is the source file

the 2nd argument is the target file

puts ARGV[0]
puts ARGV[1]

#Get the arguments and assign as files
sourceFilename = ARGV[0]
targetFilename = ARGV[1]

What is the issue here ? Seems more todo with the environment…

TIA,
Tuka

Tuka O. wrote:

#Get the arguments and assign as files
sourceFilename = ARGV[0]
targetFilename = ARGV[1]

Did you copy and paste that? Because the error message complains about
ARG,
but there’s only ARGV in the code - which doesn’t make any sense…

Thanks Sebastian,

That is what I needed. My Bad and some confusion with the editor I am
using… I was editing a similarly named file elsewhere and running the
errant file yielding the same bad result.

Thanks again,
Tuka

Sebastian H. wrote:

Tuka O. wrote:

#Get the arguments and assign as files
sourceFilename = ARGV[0]
targetFilename = ARGV[1]

Did you copy and paste that? Because the error message complains about
ARG,
but there’s only ARGV in the code - which doesn’t make any sense…

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