Forum: IronRuby Implementing get_Item in Ruby for access in .NET

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Xerxes B. (Guest)
on 2009-04-29 16:06
(Received via mailing list)
Hi there.

We're trying to access a ruby implementation of a Hash from .NET but
having trouble getting the following snip to work

require 'Dependencies.dll'
class ParameterList
       include Namespace::IParameterList


       def initialize
               @parameter_hash =

       def []= key, value
               @parameter_hash[key] = value

       def [] key

       def get_Item key

and on the .NET side:

public interface IParameterList : IEnumerable
   int Count { get; }
   IParameter this[string name] { get; }
   IParameter this[int index] { get; }
   IEnumerator GetEnumerator();
   event ParameterValueChangedEventHandler OnParameterValueChanged;

When we call it from .NET with the following code (The parameters
object is an instance of the Ruby ParamterList class ):
parameter = parameters["Key"];

The error returned is
NoMethodError: undefined method `get_Item' for

Is it possible to have a Ruby object with an indexer which is callable
from C#?

Curt H. (Guest)
on 2009-04-29 19:39
(Received via mailing list)
I don't think there's any attempt right now to identify an indexer when
overriding virtual methods.  This means that the normal Rubification
rules kick in and you get

def item key
def item= key, value

The second of these, of course, isn't usable from within Ruby -- though
I think it should still work correctly when called by C# through the

Obviously, this should be entered as a work item on Codeplex if it isn't
there already.
This topic is locked and can not be replied to.