Why cant there be classes inside methods in Ruby? <p>Can I create Ruby classes within functions bodies ? I seem to be getting error which tells me its not allowed but I think it should be as classes are too objects here.</p> <pre> class A def method class B end end end</pre> <p>This fails with error 'class definition inside method body. If we cant, why cant we create classes inside methods ?</p>