On Thursday, March 08, 2012 23:54:21 deadalnix wrote: > Le 08/03/2012 07:15, Jonathan M Davis a écrit : > > On Thursday, March 08, 2012 00:52:57 Nick Sabalausky wrote: > >> "Ary Manzana"<[email protected]> wrote in message > >> news:[email protected]... > >> > >>> Here's something I wrote today: > >>> > >>> parent_ids = results.map{|x| > >>> x['_source']['parent_ids']}.flatten.uniq.compact > >>> Hash[Site.find(parent_ids).map{|x| [x.id, x]}] > >> > >> When you format it like that (that is to say, when you *don't* format > >> it), > >> yea, it's unreadable. Which is why I do such things like this: > >> > >> parent_ids = > >> > >> results > >> .map{|x| x['_source']['parent_ids']} > >> .flatten.uniq > >> .compactHash[ > >> > >> Site.find(parent_ids).map{|x| [x.id, x]} > >> > >> ] > > > > I actually tend to find code like that hard to read, because all of the > > operations are inside out in comparison to normal. But since the only > > difference between his example and yours is the formatting, I agree yours > > is easier to read. Still, I'd much prefer if such code didn't use UFCS, > > since I find it much harder to read that way. It's just so backwards. > > > > - Jonathan M Davis > > You got tricked by your experience. You are used to read backward. The > function are written in the order they are executed in the example > above. This isn't very traditional, and may be the reverse order of what > people expect due to previous experience, but definitively is the > forward way.
I mean that it is backwards from what is normal. The result of that is that I find it harder to read. So yes, you could say that it's executing "forward," since the functions are executed from left-to-right instead of right-to-left, but regardless, it's backwards from what is normal and therefore feels very backwards to me, which is my point. - Jonathan M Davis
