IronRuby 1.1 with LINQ support

by DotNetNerd 20. July 2010 08:37

Finally LINQ is supported in IronRuby now from v. 1.1 and I think it has been solved quite elegantly without any real syntactical gooeyness. Trying it out has been made very straight forward by looking at the 101 LINQ samples rewrite for IronRuby.

From day one LINQ has seemed a natural fit with IronRuby already having a similar approach with functions such as .each {|item| ...} which is accessible on anything that can be enumerated - very much like a big part of LINQ is extentions methods to the IEnumerable interface. No doubt there has been some challanges around how to map generics, extention methods etc between the languages, but syntactically it seems a natural fit.

products.where(lambda { |p| p.units_in_stock > 0 and p.unit_price > 3.00 }).each { |x| puts x.product_name }

Combining functional methods from LINQ with the existing Ruby methods just makes the "Integrated Query" syntax even better. So now we get a .each method with LINQ even though Microsoft originally didn't want to include it :)


Tags: ,

Who am I?

My name is Christian Holm Diget, and I work as an independent consultant, in Denmark, where I write code, give advice on architecture and help with training. On the side I get to do a bit of speaking and help with miscellaneous community events.

Some of my primary focus areas are code quality, programming languages and using new technologies to provide value.

Microsoft Certified Professional Developer

Microsoft Most Valuable Professional

Month List