News for hackers. Stuff that matters.
Re:Dart language by cubicle67 on Monday October 10, 2011 @10:05AM (#3093791)
thanks. I've been writing Ruby for a few years now and I never knew about sort_by. Looks like is works in 1.8 too, but without the &: syntax

    sort_by{|g|g.irrelevance}
source: http://www.ruby-doc.org/core-1.9.2/Enumerable.html#method-i-...
Re:Dart language by jeltz on Monday October 10, 2011 @10:40AM (#3093947)
I actually believe the &:symbol syntax was added in 1.8.7 since I am 100% positive we use that in our codebase which still has not been ported to 1.9.

  $ ruby -e 'puts VERSION; p ["10", "2", "3"].sort_by(&:to_i)'
  1.8.7
  ["2", "3", "10"]
Re:Dart language by koenigdavidmj on Monday October 10, 2011 @01:12PM (#3094725)
Rails adds it too, even if your version of Ruby does not support it. Yay monkeypatching!

EDIT: said duck typing first. It's too early for thinking.