Clifford Heath
2/18/2007 4:08:00 AM
dblack@wobblini.net wrote:
>> My full example has type checking, and whether nil is allowed.
> I'll bet you mean class checking :-) But that's another (long)
> story....
It is. class checking is a limited form of type checking however, and
you can omit class checking and/or let the block can do whatever extra
type checking is needed. :-) It's nice to automatically allow/disallow
assignment of nil also.
Thanks for the note on do...end, I almost never use it, but this is a
rare case where having the same feature at a different precedence is
a good idea.
This is ready to be made a gem when I've done the unit tests. I think
I'll call it "checked". I use the "method as superclass" magic to
create checked subclasses of Array, and support both simple attributes
(with a default value) and array attributes. Hmm, perhaps I should do
hashes also... later :-).
Clifford Heath.