From: Assaph Mehr Date: 2005-04-19T09:54:35+09:00 Subject: Re: non-constant class names Chris Pine wrote: > Out of curiosity, why are we prevented from making non-constant class > names? We can make anonymous classes, we can assign them to > variables, so why not this? > > class foo > end > > Any good reason? I think it's a design issue - Ruby (well Matz :) is trying to make you program coherently. Yes, you can do: foo = Class.new do ... end But you should think about what you're trying to achieve. Seeing something like this in the code should alert you that there is some clever, subtle trick going on. When you look at the Code you should be able to understand it easily by reading it. Keeping is simple - some_text is a method, ALL_COLORS is a constant and SomeThing is a class - makes it easier. In your example is 'foo' a variable in some scope? a method from some parent class / included module? BTW, there are classes with small letters only: irb(main):001:0> ObjectSpace.each_object(Class) { |k| p k if k.name =~ /^[a-z]/ } #=> fatal But that is obviously a very special case. Cheers, Assaph