From: Robert Dober Date: 2008-05-24T00:04:57+09:00 Subject: Re: Prevent ruby constant variables from changing? > (note, you just operationaly demonstrated what XNoria wrote in prev post :) yes as you were repeating all I had done, obviously I did not succeed in expressing my intent, sorry > > > > ruby's behaviour is to get the class name fr the very first constant it encounters or it is assigned to. yes, by the very fact that _it_ is a constant. sorry, but what could be simpler? Simple????? I mean I can understand that behavior, but I feel it is very mean to do such things ;). No really, why the heck is Ruby doing this, what could it be good for? > We've assigned it to a constant, and still we expect it to have no name?? But hey, again, it's just a name. maybe what is confusing here is the word "name" itself :) you got me;) # > # irb(main):006:0> _ = Class::new > # => # > # irb(main):007:0> _.name > # => "" > > in ruby1.9, this is nil. wc mean, we have no name yet. better than saying my name is empty. > > > btw careful w using "_" in irb, since irb uses it :) True enough, but I have tested it - surprisingly enough ;) - with Ruby and Ruby1.9 I guess it is always dangerous to use irb to show some sophisticated behavior, good point. > > > # irb(main):008:0> X = _ > # => "" > > of course, since the last result was "" of course, of course, but there are shocking consequences, unless, and that is my point, one does not need Class#name. > > # irb(main):009:0> X.name > # NoMethodError: undefined method `name' for "":String > # from (irb):9 > # from :0 > # irb(main):010:0> > > as expected as I would like to expect for all classes. > > > kind regards -botp Cheers Robert -- http://ruby-smalltalk.blogspot.com/ --- Whereof one cannot speak, thereof one must be silent. Ludwig Wittgenstein