I just noticed this little quirk. Is there something
I am doing wrong?
module Mod
def *(other)
puts "#{self} * #{other}"
end
end
class String
include Mod
end
"ff" * 5 #=> nothing
But, if I add the method explicitly instead of through a module I get:
class String
#include Mod
def *(other)
puts "#{self} * #{other}"
end
end
"ff" * 5 #=> "ff" * 5
This seems to be a quirk (bug?) and only happens when mixing modules,
built in classes (like Array) and operator methods.
Mixing in a module works fine with the combinations:
Non built-in class, operators
Built-in class, non operator method
--
Jim Freeze