From: pat eyler Date: 2005-05-25T06:24:34+09:00 Subject: Re: new article On 5/24/05, Brian Schr�der wrote: > Just started with your article, and I wonder why you build a > constructor that tests for object classes, why not simply call .to_s > on the argument? I wrote it that way to create some (artificial, but easy to see) boundary conditions for the article, this test doesn't actually show up in the released versions of r43. It would have been better to be able to verify the format of the id strings, but I wasn't able to find that kind of information about them. Actually testing it the way I did was a bit of a stretch. In the case of the test key '1234' you could have a Numeric, but the real keys all seem to be alphanumeric. It's certainly possible to create an Array that would be stringified into a valid key as well, e.g. ["1", "2", "3", "4"]. > > class T > attr_reader :key > > def initialize(key) > @key = key.to_s > end > en > > [T.new(1).key, T.new("1").key, T.new([1]).key] => ["1", "1", "1"] > > best regards, > > Brian > > -- > http://ruby.brian-schroeder.de/ > > Stringed instrument chords: http://chordlist.brian-schroeder.de/ > > -- thanks, -pate ------------------------- We are often unable to tell people what they need to know, because they want to know something else, and would therefore only misunderstand what we said - the Raven (George MacDonald, Lilith)