ruby -v === ruby 1.8.2 (2004-12-25) [powerpc-aix184.108.40.206]
Please don’t laugh at my simplistic coding “techniques?”
I am reading a file which contains 1041 one token records into an array:
f_lus = File.open("/file_name", “r”)
lus = Array.new
lus = File.read("/file_name")
When I print the size of the array lus it shows: 14377.
So I figured that this has to do with the end of line chars at the end
each record/token. However, if you have 1 nl char per record the size
be twice the number of records or 2082 and not 14,377.
I went ahead and created a new array as follows, from the old array in
i = 0
newArray = Array.new
lus.each do |lu|
newArray[i] = lu
i += 1
Now when I puts the size of array newArray it prints 1041 correctly.
What is happening here, please?
Second, is there a way to chomp a record as it is read into the array?