J
Justin To
class Box
attr_reader :exceptions
def initialize
exceptions = Hash.new
end
def exceptions?
if(!exceptions.empty?)
puts "error"
else
puts "No exceptions found."
end
end
end
box = Box.new
box.exceptions?
This prints out the error: TEST.rb:11:in `exceptions?': undefined method
`empty?' for nil:NilClass (NoMethodError)
from TEST.rb:23
Why is my exceptions hash a NilClass??
Thanks!!
attr_reader :exceptions
def initialize
exceptions = Hash.new
end
def exceptions?
if(!exceptions.empty?)
puts "error"
else
puts "No exceptions found."
end
end
end
box = Box.new
box.exceptions?
This prints out the error: TEST.rb:11:in `exceptions?': undefined method
`empty?' for nil:NilClass (NoMethodError)
from TEST.rb:23
Why is my exceptions hash a NilClass??
Thanks!!