[Ironruby-core] Linq etc.

Mike Moore blowmage at gmail.com
Mon Jan 21 18:26:35 EST 2008

John, my understanding is the Where() and OrderBy() methods are extension
methods defined in System.Linq.Enumerable and only available in C# if you
include a reference to the System.Linq namespace in your C# code.  Are you
saying that extension methods are available from IronRuby without having to
require the namespace?  If not, how do we make them available?

Here is an example using an extension method with the signature "public bool
IsGuid(this String str)" in the class MyString in the namespace

C# pseudo code:

using MyAssembly.MyStuff;

public class MyStupidApp() {
 public void DoStuff(string val) {
    if (val.IsGuid()) Console.WriteLine("Guid!)

What is the equivalent Ruby code?  Do we need to require the assembly?

require 'MyAssembly.MyStuff'

def do_stuff(val)
  puts 'Guid' if val.is_guid

Or are the Linq extension methods the only ones that will be available?


On Jan 21, 2008 3:19 PM, John Messerly <jomes at microsoft.com> wrote:

> Ivan Porto Carrero:
> > What are the plans regarding Linq support for IronRuby. In the
> > presentations I've seen you were using vbx to perform linq stuff in
> > Silverlight. Is that only applicable to the from .. where ... select
> > syntax and we can still use the extension method syntax
> > collection.where ?
> Yup, you'll be able to use Linq methods using the normal method call
> syntax. There won't be special syntax.
> Translating this example:
> http://msdn2.microsoft.com/en-us/library/bb397947.aspx, it will look
> something like this:
> require 'System.Core'
> numbers = [5, 10, 8, 3, 6, 12]
> numbers.where { |num| num % 2 == 0 }.order_by { |n| n }.each { |i|
> write("#{i} ") }
> - John
> _______________________________________________
> Ironruby-core mailing list
> Ironruby-core at rubyforge.org
> http://rubyforge.org/mailman/listinfo/ironruby-core
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/ironruby-core/attachments/20080121/229d7d93/attachment.html 

More information about the Ironruby-core mailing list