<div dir="ltr">You should call generic methods a bit differently. <div><br></div><div>The next code works:<div>ret_val = c.method(:do_something_else).of(String).call(str)</div><div><br></div><div>Shay.</div><div>--------------------------------------------------------<br>
Shay Friedman | .NET Technologies Expert | Author of IronRuby Unleashed | Sela Technology Center<br>Blog: http://IronShay.com | Twitter: <a href="http://twitter.com/ironshay">http://twitter.com/ironshay</a> <br>
<br><br><div class="gmail_quote">On Thu, Feb 11, 2010 at 4:44 PM, Michael Erasmus <span dir="ltr">&lt;<a href="mailto:michaelerasmus@gmail.com">michaelerasmus@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Thanks Shay.<div><br></div><div>OK your code works. But my trouble seems to come in with the Generic method. </div><div><br></div><div>When I do:<div><br></div><div><div><div class="im"><div>public class Class1</div><div>
    {</div><div>        public string DoSomething(ref string test)</div>
<div>        {</div><div>            test = test + &quot;tamtamtam&quot;;</div><div><br></div><div>            return &quot;return value&quot;;</div><div>        }</div><div><br></div></div><div>        public string DoSomethingElse&lt;T&gt;(ref T test)</div>

<div>        {</div><div>            return test.ToString(); </div><div>        }</div><div>    }</div></div><div><br></div>and then call it from IR:</div><div><br></div><div><br></div><div><div><div>&gt;&gt;&gt; c = TestClass::Class1.new</div>

<div>=&gt; TestClass.Class1</div><div>&gt;&gt;&gt; c.do_something(&quot;Bla&quot;)</div><div>=&gt; [&#39;return value&#39;, &#39;Blatamtamtam&#39;]</div><div>&gt;&gt;&gt; c.do_something_else(&quot;Bla&quot;)</div><div class="im">
<div>Microsoft.Scripting.Core:0:in `Bind&#39;: Expression of type &#39;IronRuby.Builtins.Muta</div>
<div>bleString&amp;&#39; cannot be used for parameter of type &#39;IronRuby.Builtins.MutableStrin</div></div><div>g&#39; of method &#39;System.String DoSomethingElse[MutableString](IronRuby.Builtins.Mut</div><div>ableString ByRef)&#39; (ArgumentError)</div>
<div class="im">
<div>        from Microsoft.Scripting.Core:0:in `BindCore&#39;</div></div><div>        from :0</div><div><br></div><div><br></div><div><br></div></div><div><div></div><div class="h5"><div><br></div><div class="gmail_quote">
On Thu, Feb 11, 2010 at 4:12 PM, Shay Friedman <span dir="ltr">&lt;<a href="mailto:shay.friedman@gmail.com" target="_blank">shay.friedman@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>It returns another return value with the new ref value.</div><div><br></div><div>For example, if you have the next c# class:</div>

<div><div>public class Class1</div><div>{</div><div>    public string DoSomething(ref string test)</div>
<div>    {</div><div>        test = test + &quot;tamtamtam&quot;;</div><div><br></div><div>        return &quot;return value&quot;;</div><div>    }</div><div>}</div><div><br></div><div>This is the IronRuby code you can write to use it:</div>


<div><div>&gt;&gt;&gt; require &#39;c:\dev\TestApps\TestClass\TestClass\bin\Debug\TestClass.dll&#39;</div><div>=&gt; true</div><div>&gt;&gt;&gt; c = Class1.new</div><div>=&gt; TestClass.Class1</div><div>&gt;&gt;&gt; str = &quot;hello&quot;</div>


<div>=&gt; &quot;hello&quot;</div><div>&gt;&gt;&gt; result = c.do_something(str)</div><div>=&gt; [&#39;return value&#39;, &#39;hellotamtamtam&#39;]</div><div><br></div><div>Pay attention that the result variable is an array that contains the method return value as the first item and the ref value as the second parameter.</div>


<div><br></div><div>Shay.</div></div></div>--------------------------------------------------------<br>Shay Friedman | .NET Technologies Expert | Author of IronRuby Unleashed | Sela Technology Center<br>Blog: http://IronShay.com | Twitter: <a href="http://twitter.com/ironshay" target="_blank">http://twitter.com/ironshay</a> <br>



<br><br><div class="gmail_quote"><div><div></div><div>On Thu, Feb 11, 2010 at 3:44 PM, Michael Erasmus <span dir="ltr">&lt;<a href="mailto:michaelerasmus@gmail.com" target="_blank">michaelerasmus@gmail.com</a>&gt;</span> wrote:<br>

</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div></div><div>
Hi Everyone,<div><br></div><div>I&#39;m trying to write a IronRuby script that interops with a a .NET assembly written in C#.  </div><div><br></div><div>It has a class that derives from a base class in the .NET assembly. One of the base class protected methods looks like this:</div>



<div><br></div><div><div>protected void OnNotifyPropertyChanged&lt;T&gt;(string name, ref T localmember, T value)</div><div> {</div><div>         ......</div><div> }</div><div><br></div><div>I can&#39;t for the life of me figure out how to call this method from IR in my derived class.</div>



<div>The documentation mentions that you can call <b>out </b>parameters without using them as arguments, but I can&#39;t seem to find anything about <b>ref </b>params.</div><div><br></div><div>If I just try calling the method like this:</div>



<div><br></div><div>OnNotifyPropertyChanged(property_name, value, value)</div><div><br></div><div>I get this error:</div><div><br></div><div><div><i>Microsoft.Scripting.Core:0:in `Bind&#39;: Expression of type &#39;IronRuby.Builtins.Muta</i></div>



<div><i>bleString&amp;&#39; cannot be used for parameter of type &#39;IronRuby.Builtins.MutableStrin</i></div><div><i>g&#39; of method &#39;Void #base#OnNotifyPropertyChanged[MutableString](System.String, I</i></div><div>



<i>ronRuby.Builtins.MutableString ByRef, IronRuby.Builtins.MutableString)&#39; (Argumen</i></div><div><i>tError)</i></div><div><i>        from Microsoft.Scripting.Core:0:in `BindCore&#39;</i></div><div><i>        from ./dynamic_event_item.rb:22:in `method_missing&#39;</i></div>



<div><i>        from :0</i></div><div><br></div><div><br></div><div>Am I missing something?</div><div><br></div><div>Thanks</div><div><br></div><div>Michael Erasmus</div><div><br></div></div></div>
<br></div></div>_______________________________________________<br>
Ironruby-core mailing list<br>
<a href="mailto:Ironruby-core@rubyforge.org" target="_blank">Ironruby-core@rubyforge.org</a><br>
<a href="http://rubyforge.org/mailman/listinfo/ironruby-core" target="_blank">http://rubyforge.org/mailman/listinfo/ironruby-core</a><br>
<br></blockquote></div><br></div>
<br>_______________________________________________<br>
Ironruby-core mailing list<br>
<a href="mailto:Ironruby-core@rubyforge.org" target="_blank">Ironruby-core@rubyforge.org</a><br>
<a href="http://rubyforge.org/mailman/listinfo/ironruby-core" target="_blank">http://rubyforge.org/mailman/listinfo/ironruby-core</a><br>
<br></blockquote></div><br></div></div></div></div>
<br>_______________________________________________<br>
Ironruby-core mailing list<br>
<a href="mailto:Ironruby-core@rubyforge.org">Ironruby-core@rubyforge.org</a><br>
<a href="http://rubyforge.org/mailman/listinfo/ironruby-core" target="_blank">http://rubyforge.org/mailman/listinfo/ironruby-core</a><br>
<br></blockquote></div><br></div></div></div>