If you understood correctly, this should work:
class Solution
attr_reader :analyzers
def initialize()
@analyzers = []
end
def analyze_file()
count = 0;
File.open('test.txt').each_line do |line|
la = LineAnalyzer.new(line, count)
@analyzers.push la
count += 1
end
end
end
Distracting from the question, note that in most places in the ruby you do not need ;. Ruby is good, so it does not complain about it, but it is useful to stay with standard conventions.
source
share