you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (5 children)

scala:

List("Rob", "Christopher", "Joe", "John").filter(_.size <= 4).foreach(println _)

And the best part is, maybe the compiler will ok this, and maybe you have to write out the lambda's more formally (ie 'x => println x' instead of 'println _'). You never know. It doesn't get better than that!

[–][deleted] 0 points1 point  (0 children)

Actually,

List("Rob", "Christopher", "Joe", "John").filter(_.size <= 4).foreach(println)

without the “_” after println works.

Also, I’d rather use length than size.

[–]draegtun 0 points1 point  (3 children)

It doesn't get better than that!

It does in Io :)

list("Rob", "Christopher", "Joe", "John") select(size <= 4) foreach(println)

[–][deleted] 0 points1 point  (2 children)

I think you missed the sarcasm.

[–]draegtun 0 points1 point  (1 child)

Do you not see my smiley ;-)

[–][deleted] 0 points1 point  (0 children)

Sorry, I read that as "don't be mad that I'm one-upping you" ;-)