Loading text lines to array

Hello

I have an exercise to do at school. I have to make a identity cards rtf
file
from text file with list of people. I started while ago and have a
little problem with loading text lines to array

path = STDIN.gets
path.chop!

File.open path do |f|
f.each_line {|ln| people << ln}
end

in 'block (2 levels) in ': undefined local variable or method
‘osoba’ for main:Object (NameError)

Hi.

If you replace names in your example-code, you should also adapt the
error-message that you report.

Better even, run the code with the altered names and give us an
authentic example.

The error-message above says that you had not defined the array osoba
before using it.

In the code-example, the array people is not defined.

people = [];[“me”, “you”, “her”, “they”].each {|v| people << v}

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