Forum: IronRuby IronRuby .Net 4 CTP and dynamic

Posted by Patrick Brown (Guest)
on 2009-11-13 18:41
(Received via mailing list)
Hi

   Should I be able to call out to a C# method with this release that
returns a dynamic and access it's return value?

public class Modifier
{
 public dynamic Modify(IPropertyPolicyInfo info)
 {
  dynamic obj = new ExpandoObject();
  obj.Name = info.AccountShortName;
  obj.Address = new ExpandoObject();
  obj.Address.LineOne = info.PolicyHQAddressLine1;
  obj.Address.City = info.PolicyHQCityName;
  return obj;
 }
}

I get an exception saying "Unbound variable:value" when puts attempts to
access t.Name.  I watch it in the debugger and can see that the dynamic
object is fully populated prior to sending back to the script.

policies.each { |info|
    t =  modifier.Modify(info)
    puts t.Name
}

Thanks,
Patrick
Posted by Kevin Radcliffe (Guest)
on 2010-03-03 20:07
(Received via mailing list)
Patrick,
  Tomas made a fix for dynamic, and it is now included in the latest 
source
from git:
  http://github.com/ironruby/ironruby

  If you build the latest from source (make sure you build the "V4 
Release"
(or V4 Debug) from ruby4.sln),
  your code (which deals with the ExpandoObject) should work as you 
expect.
  Thanks

Best Regards,
Kevin Radcliffe
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.