The following code:
class Avalon
def h
puts "petrezselyem"
end
end
Avalon.new.h
prints out "petrezselyem". However, if I type:
puts Avalon.new.h.size
It gives
undefined method `size' for nil:NilClass (NoMethodError).
Could you please explain this behaviour?
Look at the signature of Kernel#puts:
This means
putswill always returnniland since it’s the last statement in thehmethod, this will also be the return value of that method.