From: John Lane Date: 2010-04-17T07:09:25+09:00 Subject: Re: Blocks and local variable creation Rick Denatale wrote: > > I think you meant rights_held instead of rights_hash in that second > line. > Yes I did' Serves me right for doing two things at once ;) > > My inclination would be to do something like > > perform_something_with_rights(rights_for_item(rights_hash, item)) > > Let the thing which needs the rights deal with what rights it has, and > an empty collection(array) of rights seems a better representation of > empty rights than nil. > Yes, I agree. I'm convinced of the argument for returning the same type. Makes a lot of sense when you come to think of it. I found the explanation from Jesus about (&:first) very interesting but I'm not sure I think it improves readability. I read these: http://pragdave.pragprog.com/pragdave/2005/11/symbolto_proc.html http://www.ruby-forum.com/topic/161089 Personally I think the Symbol#to_proc approach is less idomatic than the long hand version but I guess it's a matter of personal taste. -- Posted via http://www.ruby-forum.com/.