[Ironruby-core] Calling overloaded methods

Tomas Matousek Tomas.Matousek at microsoft.com
Fri Jan 9 12:17:40 EST 2009


[3,4] is not an array of objects. It's a RubyArray. 

You can create a CLR array like this:

v = System::Array.of(Object).new(3)
[1,2,3].each_with_index { |x,i| v[i] = x }

Tomas

-----Original Message-----
From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Alex 2k8
Sent: Friday, January 09, 2009 8:17 AM
To: ironruby-core at rubyforge.org
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
Ironruby-core at rubyforge.org
http://rubyforge.org/mailman/listinfo/ironruby-core



More information about the Ironruby-core mailing list