nobu.nokada / softhome.net writes: > Hi, > > At Sat, 28 Aug 2004 19:08:11 +0900, > George Ogata wrote in [ruby-core:03328]: >> That is, #define_method makes private methods when sent from outside, >> but makes public methods when called on `self'. Actually, it outputs >> the latter in irb, but not in naked ruby. > > The scope in class block is public by default, but private in > top-level. And #define_method defines the method with the > current visibility. > > class C; end > public > C.send(:define_method, :f){} > p C.public_instance_methods.include?('f') > > prints true. > > I'm not sure this should be modified. Ah, that makes sense. Thanks. It seemed dubious when #send-ing it from outside, but I guess it has to work that way for: class C public/private/whatever... define_method(:f){} end ...to work as expected.