Hacker News new | ask | show | jobs
by dstorrs 4945 days ago
Ok, tell me if I have this correct:

  module Foo
    def hello
      puts "Hello World"
    end
  end

  ...in a different file...

  foo = Foo.new.msg
Q: What does that print? A: There is no way to tell. It depends on what the 'using' line (not shown) is, and whether anything has refined 'Foo'.

Seems like bad action at a distance, to me. Or am I missing something? The example about the effects of refining 'each' is also pretty disconcerting.

2 comments

Seems like a NoMethodError to me.
NoMethodError: undefined method `new' for Foo:Module

You can't initialize modules, I think you meant to make Foo a class.