I can''t figure out how to get items out of any of the CLR List types in IronRuby. Here''s a contrived example:>>> require ''mscorlib''=> true>>> foo = System::Collections::ArrayList.new()=> #<ArrayList:0x0000056>>>> foo.Item(0)System.MissingMethodException: undefined local variable or method `Item'' for #<ArrayList:0x0000056>:ArrayList Here''s the only thing I could think of that does work:>>> foo.ToArray.GetValue(0)=> "Hello" Does anyone know why that is? Or maybe a better work-around? Thanks! -Eric -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ironruby-core/attachments/20071011/517c213d/attachment.html
On 10/11/07, Eric Nicholson <enicholson at gmail.com> wrote:> > I can''t figure out how to get items out of any of the CLR List types in > IronRuby. Here''s a contrived example: > > >>> require ''mscorlib'' > => true > >>> foo = System::Collections:: ArrayList.new() > => #<ArrayList:0x0000056> > >>> foo.Item(0) > System.MissingMethodException: undefined local variable or method `Item'' > for #<ArrayList:0x0000056>:ArrayListThe actualy method name will be get_Item(), I think. But did you try>>> foo[0]Might work! Justin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ironruby-core/attachments/20071011/750908ab/attachment.html
Good Call. foo.get_Item() works great. foo[0] throws an exception. Thanks Justin! That''s much better than ToArray.GetValue... -Eric On 10/11/07, Justin Bailey <jgbailey at gmail.com> wrote:> > On 10/11/07, Eric Nicholson <enicholson at gmail.com> wrote: > > > > I can''t figure out how to get items out of any of the CLR List types in > > IronRuby. Here''s a contrived example: > > > > >>> require ''mscorlib'' > > => true > > >>> foo = System::Collections:: ArrayList.new() > > => #<ArrayList:0x0000056> > > >>> foo.Item(0) > > System.MissingMethodException: undefined local variable or method `Item'' > > for #<ArrayList:0x0000056>:ArrayList > > > The actualy method name will be get_Item(), I think. But did you try > > >>> foo[0] > > Might work! > > Justin > > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ironruby-core/attachments/20071011/02974de6/attachment.html
And if anyone is wondering, the set would be: foo.set_Item(0, "World") Cory From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Eric Nicholson Sent: Thursday, October 11, 2007 4:00 PM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Referencing a CLR List in IronRuby Good Call. foo.get_Item() works great. foo[0] throws an exception. Thanks Justin! That''s much better than ToArray.GetValue... -Eric On 10/11/07, Justin Bailey <jgbailey at gmail.com<mailto:jgbailey at gmail.com>> wrote: On 10/11/07, Eric Nicholson <enicholson at gmail.com<mailto:enicholson at gmail.com>> wrote: I can''t figure out how to get items out of any of the CLR List types in IronRuby. Here''s a contrived example:>>> require ''mscorlib''=> true>>> foo = System::Collections:: ArrayList.new()=> #<ArrayList:0x0000056>>>> foo.Item(0)System.MissingMethodException: undefined local variable or method `Item'' for #<ArrayList:0x0000056>:ArrayList The actualy method name will be get_Item(), I think. But did you try>>> foo[0]Might work! Justin _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org<mailto:Ironruby-core at rubyforge.org> http://rubyforge.org/mailman/listinfo/ironruby-core -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ironruby-core/attachments/20071011/2061389c/attachment.html
We''ll have foo[0] working sometime later today. John Messerly just checked in support for injecting each() into IEnumerable things (among other nice interop pieces). He just missed out on the IList case. Thanks, -John From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Cory Foy Sent: Thursday, October 11, 2007 1:09 PM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Referencing a CLR List in IronRuby And if anyone is wondering, the set would be: foo.set_Item(0, "World") Cory From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Eric Nicholson Sent: Thursday, October 11, 2007 4:00 PM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Referencing a CLR List in IronRuby Good Call. foo.get_Item() works great. foo[0] throws an exception. Thanks Justin! That''s much better than ToArray.GetValue... -Eric On 10/11/07, Justin Bailey <jgbailey at gmail.com<mailto:jgbailey at gmail.com>> wrote: On 10/11/07, Eric Nicholson <enicholson at gmail.com<mailto:enicholson at gmail.com>> wrote: I can''t figure out how to get items out of any of the CLR List types in IronRuby. Here''s a contrived example:>>> require ''mscorlib''=> true>>> foo = System::Collections:: ArrayList.new()=> #<ArrayList:0x0000056>>>> foo.Item(0)System.MissingMethodException: undefined local variable or method `Item'' for #<ArrayList:0x0000056>:ArrayList The actualy method name will be get_Item(), I think. But did you try>>> foo[0]Might work! Justin _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org<mailto:Ironruby-core at rubyforge.org> http://rubyforge.org/mailman/listinfo/ironruby-core -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ironruby-core/attachments/20071011/02af55f3/attachment-0001.html
Sweet! Thanks Guys! On 10/11/07, John Lam (DLR) <jflam at microsoft.com> wrote:> > We''ll have foo[0] working sometime later today. John Messerly just > checked in support for injecting each() into IEnumerable things (among other > nice interop pieces). He just missed out on the IList case. > > > > Thanks, > > -John > > > > > > *From:* ironruby-core-bounces at rubyforge.org [mailto: > ironruby-core-bounces at rubyforge.org] *On Behalf Of *Cory Foy > *Sent:* Thursday, October 11, 2007 1:09 PM > *To:* ironruby-core at rubyforge.org > *Subject:* Re: [Ironruby-core] Referencing a CLR List in IronRuby > > > > And if anyone is wondering, the set would be: > > > > foo.set_Item(0, "World") > > > > Cory > > > > *From:* ironruby-core-bounces at rubyforge.org [mailto: > ironruby-core-bounces at rubyforge.org] *On Behalf Of *Eric Nicholson > *Sent:* Thursday, October 11, 2007 4:00 PM > *To:* ironruby-core at rubyforge.org > *Subject:* Re: [Ironruby-core] Referencing a CLR List in IronRuby > > > > Good Call. foo.get_Item() works great. foo[0] throws an exception. > > Thanks Justin! That''s much better than ToArray.GetValue... > > -Eric > > On 10/11/07, *Justin Bailey* <jgbailey at gmail.com> wrote: > > On 10/11/07, *Eric Nicholson* <enicholson at gmail.com> wrote: > > I can''t figure out how to get items out of any of the CLR List types in > IronRuby. Here''s a contrived example: > > >>> require ''mscorlib'' > => true > >>> foo = System::Collections:: ArrayList.new() > => #<ArrayList:0x0000056> > >>> foo.Item(0) > System.MissingMethodException: undefined local variable or method `Item'' > for #<ArrayList:0x0000056>:ArrayList > > > The actualy method name will be get_Item(), I think. But did you try > > >>> foo[0] > > Might work! > > Justin > > > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > > > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ironruby-core/attachments/20071011/40ecaf62/attachment.html