From: David Alan Black Date: 2001-02-27T05:40:38+09:00 Subject: [ruby-talk:11626] some weird eval behavior Hello -- This question grows out of playing around with a question from Clemens W., although I'm afraid it doesn't shed any light on Clemens's question... just more darkness... # Define two new methods for Module, one eval'd, one not: eval('class Module; def test(); end; end;'); class Module private def thing end end # Test both methods for respond_to? and for being private: if Module.respond_to?(:test) then puts "responds to test" else puts "does not respond to test" end if Module.private_methods.include? "test" then puts "test is private" else puts "test is not private" end if Module.respond_to?(:thing) then puts "responds to thing" else puts "does not respond to thing" end if Module.private_methods.include? "thing" then puts "thing is private" else puts "thing is not private" end __END__ Output: responds to test test is private does not respond to thing thing is private And various other permutations also produce asymmetrical results. (I won't inline all of them -- available upon request :-) I can get it symmetrical by putting "private;" in the eval -- but the thing is it claims it *is* private anyway.... Rays of light welcome. David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav