From: Intransition Date: 2009-12-31T01:24:57+09:00 Subject: Re: Using #include at the instance level? On Dec 29, 9:04 pm, fkocherga wrote: > > AFAIK it hasn't changed and your code could never work in any version > > of Ruby because the const lookup in method #n is done _statically_. > > But it should not, consider: > > module M >   module N >   end > end > > #Class.new do <---- This does not work in 1.8.7! > class B < Object >   include M >   N > end > > When 'class B < Object' replaced with 'Class.new do' the Ruby 1.8.7 interpreter complains about uninitialized constant N. What is the big reason for dynamically defined class to behave so differently? It would be very non obvious and unexpected behavior. Actually both cases work as expected in Ruby 1.9.1 and this is correct behavior according to the Ruby Draft. Nice clarification. Are there two issues here? This issue and the resolution of constants via instance_eval? Or are these two aspects of the same issue? In either case, there is no doubt in my mind that 'class B' and 'B = Class.new do' should work the same.