From: Arun Kumar Date: 2010-10-28T15:57:26+09:00 Subject: Defining nested Method in single class Hi All, Today morning i exploring the ruby 1.8.7, i found myself some what clear so that i worked some basic code concepts (class and methods) and i satisfied, Again I build a code to confuse myself. Initially it show some error, finally i made some modification on the code,and it works fine, but i thought it needs to show error, can anyone please explain how it works ? Note: ===== I created a class in class it showing Error like "class definition in method body", If its is means, why not in methods ? Code: ===== class AdavanceConfuse def AdavanceConfuse.Class_method1 puts "this is class_method1" def AdavanceConfuse.class_method1_attribute_class_method puts "this is class_method1_attribute_class_method" end class_method2 end def AdavanceConfuse.class_method2 #~ class TestClass puts "this is class_method2" def Instance_method1 puts "this is instance_method1" end #~ end end end AdavanceConfuse.Class_method1 AdavanceConfuse.class_method1_attribute_class_method AdavanceConfuse.class_method2 AdavanceConfuse.new.Instance_method1 Output: ======= this is class_method1 this is class_method2 this is class_method1_attribute_class_method this is class_method2 this is instance_method1 Forgive me if my question is stupid ?.. Thanks in Advance, Arun. -- Posted via http://www.ruby-forum.com/.