On 5/24/05, Brian Schr=F6der <> 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)=20
boundary conditions for the article, this test doesn't actually=20
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=20
of the test key '1234' you could have a Numeric, but the real keys=20
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"]. =20
>=20
> class T
> attr_reader :key
>=20
> def initialize(key)
> @key =3D key.to_s
> end
> en
>=20
> [T.new(1).key, T.new("1").key, T.new([1]).key] =3D> ["1", "1", "1"]
>=20
> best regards,
>=20
> Brian
>=20
> --
> http://ruby.brian-schroeder.de/
>=20
> Stringed instrument chords: http://chordlist.brian-schroeder.de/
>=20
>=20
--=20
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)