[Ironruby-core] More CLR interop questions - Generic Methods

Tomas Matousek Tomas.Matousek at microsoft.com
Tue Sep 9 19:19:30 EDT 2008

Generic methods are not supported yet.


From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Orion Edwards
Sent: Tuesday, September 09, 2008 3:44 PM
To: ironruby-core at rubyforge.org
Subject: [Ironruby-core] More CLR interop questions - Generic Methods

Playing around, I see that this works

include System

Generic = System::Collections::Generic

Linq = System::Linq

# var list = new List<Int32>();

list = Generic::List[Int32].new

list.add 1

list.add 2

# list.Average();

puts Linq::Enumerable.average(list) # it knows it's a list of int32

=> 1.5

This is incredibly cool by the way, however, I can't work out how to pass types to a method which needs them, such as Linq's IEnumerable.Cast.
This was my best guess, and it fails

# list.Cast<Double>();


I also tried

Linq::Enumerable.cast(Double, list)

Linq::Enumerable.cast(list, Double)


Is this actually implemented, if so how can I use do it?
Orion Edwards
Web Application Developer

T: +64 7 859 2120
F: +64 7 859 2320
E: orion.edwards at open2view.com <mailto:orion.edwards at open2view.com>

The Real Estate Website

[cid:image001.jpg at 01C91297.D6B9C3F0]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20080909/46162b76/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 8147 bytes
Desc: image001.jpg
URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20080909/46162b76/attachment-0001.jpg>

More information about the Ironruby-core mailing list