On 24/05/05, pat eyler <pat.eyler / gmail.com> wrote: > On 5/24/05, Brian Schröäer <ruby.brian / gmail.com> 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"]. > I understand your motivation, but I think it is showing something that I would rate as ugly ruby code to the world. If you really want a string, you could have used to_str. Please don't feel offended. I'm not even maintaining a library and have until now never managed to really develop something test first, let alone write an article and get it published. I feel that ugly maybe is a bit too strong a word, but I can't find anything more subtle. I think it is important to show good ruby style in articles, and ducktyping is one part of good style. best regards, Brian Schröäer -- http://ruby.brian-schroeder.de/ Stringed instrument chords: http://chordlist.brian-schroeder.de/