[Ironruby-core] overriding indexers

Jimmy Schementi Jimmy.Schementi at microsoft.com
Thu May 28 15:11:43 EDT 2009

Pretty sure this isn’t implemented yet, as you can accomplish the same type of effect with method_missing:

_inner.key2 = “value2”

It definitely should be fixed, but not sure if anyone has it in their sights. So open a bug =)

From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Ivan Porto Carrero
Sent: Thursday, May 28, 2009 10:49 AM
To: ironruby-core
Subject: [Ironruby-core] overriding indexers


How do I override an indexer on a C# class?

public class IndexerContained{

        private Dictionary<string, string> _inner = new Dictionary<string, string>{
            { "key1", "value1" },
            { "key2", "value2" },
            { "key3", "value3" },
            { "key4", "value4" }

        public virtual string this[string name]{
          get { return _inner[name]; }
          set { _inner[name] = value; }

I would like to override that indexer with something like

class IndexerContainedMock

  def [](*args)

  def []=(*args)
    # nothing here

Am I doing it wrong or is that not implemented yet?

Met vriendelijke groeten - Best regards - Salutations
Ivan Porto Carrero
GSM: +32.486.787.582
Blog: http://flanders.co.nz
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090528/81e50153/attachment.html>

More information about the Ironruby-core mailing list