var list = array.Cast<Tweet>(); would be cleaner.
On Wed, Jun 2, 2010 at 5:47 PM, Tomas Matousek <Tomas.Matousek at
microsoft.com> wrote:
> RubyArray is IList<object>, its items might be of arbitrary
(different)
> types.
>
> You can certainly try to cast all of them to a single type:
> var list = new List<Tweet>(array.Count);
> foreach (Tweet item in array) {
> list.Add(item);
> }
>
> Tomas
>
> -----Original Message-----
> From: ironruby-core-bounces at rubyforge.org [mailto:
> ironruby-core-bounces at rubyforge.org] On Behalf Of Ben Hall
> Sent: Wednesday, June 02, 2010 5:27 PM
> To: ironruby-core at rubyforge.org
> Subject: [Ironruby-core] RubyArray to List<T> ?
>
> Hello,
>
> I have a block of code which returns me a RubyArray back into C# code.
> While I can get access to the strongly typed objects inside using
> reflection, I was wondering if there was any way to get the data back as a
> List<T> ?
>
> Example of the code at the moment:
> RubyArray o = (RubyArray)
> filters[1].GetFilteredOutTweets(tweets);
> Console.WriteLine(o);
> Console.WriteLine((o[0] as Tweet).User);
>
>
> GetFilteredOutTweets returns an object as when it returned
List<Tweet> it
> was causing it to fail.
>
> Make sense?
>
> Thanks
>
> Ben
> _______________________________________________
> 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
>
--
"The explanation requiring the fewest assumptions is most likely to be
correct."
- Occam?s Razor
http://en.wikipedia.org/wiki/Occam''s_Razor
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://rubyforge.org/pipermail/ironruby-core/attachments/20100603/34395c3f/attachment.html>