From: Robert Klemme Date: 2003-08-01T16:47:26+09:00 Subject: Re: Ruby could be wildly more popular if it had ... "Gavin Sinclair" schrieb im Newsbeitrag news:36035.203.185.214.34.1059698367.squirrel@webmail.imagineis.com... > >> > >> But then you get some larger ones: > >> > >> set.map { |e| > >> if something > >> e.x > >> else > >> e.y > >> end > >> } > > > > [Robert:] > > Know your ternary operator: :-) > > set.map { |e| something ? e.x : e.y } > > I know my ternary operator, but: No offense intended. Sorry, if that sounded a bit aggressive. > - in my code snippet, "something", "e.x", and "e.y" were placeholders I see. > for something far bigger than you or I could imagine Wow... (Robert silences in awe.) :-) > - sometimes there is multi-part processing do be done before arriving > the "return value" for the block Yep. In Ruby anyway you can easily replace ?: with the far more readable set.map { |e| if something then e.x else e.y end } so it's still a one liner in this case. :-) Cheers robert