I can define a method on an instance like this:
object = Object.new
def object.foo
puts "5"
end
Trying something similar with a Fixnum
doesn't work:
def 3.foo
puts "3"
end
def 3.foo
^
(irb):7: syntax error, unexpected keyword_end, expecting end-of-input
What's the reason for this?
I know this is something I should never do. I'm just wondering why this doesn't work like I expected it to.