I don't understand why there is an error with @file_lines in my counter method. The error is: browser_count.rb:10:in `counter': undefined method `uniq' for nil:NilClass (NoMethodError) from browser_count.rb:32Code:class BrowserCount def initialize(file = "browsers.txt") @file_lines = Array.new @file = file end def counter read_file @hash = Hash.new @files_lines.uniq.each do |line| count = 0 @file_lines.each do |x| if x == line count +=1 end end @hash[line]=count end @hash end private def read_file if @file_lines.empty? @open_file = File.open(@file) @file_lines = @open_file.readlines() end end end B = BrowserCount.new B.counter





Bookmarks