C:\>ruby -v
ruby 2.0.0p0 (2013-02-24) [i386-mingw32]

C:\>irb --simple-prompt
DL is deprecated, please use Fiddle
>> N = 1
=> 1
>> obj = Object.new
=> #<Object:0x2166c00>
>> class << obj
>> N = 2
>> end
=> 2
>> def obj.a_method
>> puts N
>> end
=> nil
>> class << obj
>> def another_method
>> puts N
>> end
>> end
=> nil
>> obj.a_method
1
=> nil
>> obj.another_method
2
=> nil
>>

Both `a_method` and `another_method` are the singleton methods of the
object `obj`. Then why gave different output for `N` ?

-- 
Posted via http://www.ruby-forum.com/.