F
Francisco Martinez
Hi, I have done this method in order to put the content of a txt file
into an array. Now I should have to construct a bucle out of the method
to print the content of the array in the screen but I dont't know what
to do. This is my method:
def cargar_tokens(txtFileName)
tokens=[]
txtFile = File.open(txtFileName)
txtFile.each(" ") do |palabra|
if (palabra=~ /(.+)/)
token = $1
tokens.push(token)
end
end
txtFile.close
return tokens
end
if (ARGV.length<1)
puts "I need one argument: 1) name of the file"
else
tokens=cargar_tokens(ARGV[0])
end
into an array. Now I should have to construct a bucle out of the method
to print the content of the array in the screen but I dont't know what
to do. This is my method:
def cargar_tokens(txtFileName)
tokens=[]
txtFile = File.open(txtFileName)
txtFile.each(" ") do |palabra|
if (palabra=~ /(.+)/)
token = $1
tokens.push(token)
end
end
txtFile.close
return tokens
end
if (ARGV.length<1)
puts "I need one argument: 1) name of the file"
else
tokens=cargar_tokens(ARGV[0])
end