------ art_140862_22730577.1169127242128 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 1/18/07, Trans <transfire / gmail.com> wrote: > > <lots of interesting stuff snipped **FOR NOW**> > T > > > ps. i came across an oddity while messing with this: > > irb(main):019:0> q = {} > => {} > irb(main):020:0> q.sort_by > => [] > irb(main):021:0> q[:a] = 1 > => 1 > irb(main):022:0> q.sort_by > LocalJumpError: no block given > from (irb):22:in `sort_by' > from (irb):22 > from :0 > ruby 1.8.4 on debian Hmm is it really an oddity (I have the same behavior on 1.8.5/debian)? An empty hash sort just cannot apply the block to any elements, but I guess you know that ;). Would you prefer that sort_by just checks for the presence of a block anyway? I gotto think a lot about the rest you have written most interesting stuff, just some very quick thoughts * There are structs you know ;) * #open! could return self so that one can write h={:value=>42}.open! #close! should than too for symmetry. * Would it not be better not to hide a method in case the hash has no key? That would be a mess right? One would not know if h.size is 1 because of h[:size]=1 or h={:a=>1}.open! * I'd like to use #open! behind the scenes with a block form like class Hash def use_opened &blk open! blk.call(self) if blk close! end end or even class Hash def in_context &blk open! instance_eval &blk ..... Conclusion: Basically it is a nice idea but maybe you really want a struct. I would not think it should be in the core but in an extension like facet of course it might be spot on ;) In any case that is the kind of post which make this ML so much fun and education. Cheers Robert -- "The best way to predict the future is to invent it." - Alan Kay ------ art_140862_22730577.1169127242128--