News for hackers. Stuff that matters.
Re:First Impressions of Python from a Java Developer by DanielRibeiro on Monday November 08, 2010 @02:36PM (#1883662)
In Ruby, with ruby underscore (http://bit.ly/9dwWAX), you can write it as:

    all_users.select(_.is_admin).map _.username
Other languages have similar ways to write it concisely as well (http://bit.ly/a6QmgL). Coffeescript (which compiles to javascript, and therefore, can run on Rhinon inside the jvm) in particular:

    allowed_usernames = user.username for user in all_users when user.is_admin()
Yeah. Reminds me of http://gag.googlecode.com/svn/trunk/javadoc/com/google/gag/a...
Re:First Impressions of Python from a Java Developer by generalk on Monday November 08, 2010 @02:51PM (#1883717)
In Ruby 1.9, or Ruby 1.8 w/ ActiveSupport, you can use the & operator, which coerces it's argument (in this case, a symbol) to a Proc:

    all_users.select(&:is_admin).map(&:username)
This is a common idiom with a fantastic writeup at http://weblog.raganwald.com/2008/02/1100inject.html
Re:First Impressions of Python from a Java Developer by DanielRibeiro on Monday November 08, 2010 @03:57PM (#1883981)
Actually on ruby 1.8.7 the proc coercion is default. No need for active support. And yeah, ruby underscore is overkill for this trivial example.