You'll need to build a CLR array rather than a Ruby array.
require 'mscorlib'
System::Array.create_instance(System::Object.to_clr_type, 2)
o = System::Array.create_instance(System::Object.to_clr_type, 2)
>>> o[0] = 3
>>> o[1] = 4
You can monkey-patch Array and add this as a helper:
class Array
def to_clr_ary
o = System::Array.create_instance(System::Object.to_clr_type, length)
each_with_index { |obj, i| o[i] = obj }
o
end
end
CLR arrays and Ruby arrays are totally different; Ruby arrays are much more
similar to "List<object>" than to "object[]". So it's unlikely that IronRuby
would ever do this conversion automatically for you.
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Alex 2k8
Sent: Friday, January 09, 2009 8:17 AM
To: [email protected]
Subject: [Ironruby-core] Calling overloaded methods
Hello,
C#
public class Cls {
public void foo(object a) {
Console.WriteLine("foo #1");
}
public void foo(object[] a) {
Console.WriteLine("foo #2");
}
}
Ruby:
Cls.new.foo(7)
Cls.new.foo([3, 4])
Output:
foo #1
foo #1 <-- Calling foo(object a) again
So how can I call foo(object[] a)?
- Alex
--
Posted via http://www.ruby-forum.com/.
_______________________________________________
Ironruby-core mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ironruby-core
_______________________________________________
Ironruby-core mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ironruby-core