In this Ruby code:
Module M
Class C < Struct.new(:param)
def work
M::helper(param)
end
end
def helper(param)
puts "hello #{param}"
end
end
I get a "undefined method 'helper' for 'M:Module'" error when I try to run
c = M::C.new("world")
c.work
but calling M::helper("world")
directly from another class works fine. Can classes not call Module functions that are defined in the same Module they are defined in? Is there a way around this other than moving the class outside of the module?