[Ironruby-core] An Issue with CLR Delegates

Shay Friedman lists at ruby-forum.com
Tue Jun 9 08:34:52 EDT 2009


Today I'm playing with CLR delegates :)

I've run into a strange behavior.

Take a look at the next C# block:
public class Printer
  public delegate void PrintValue(string value);

Assuming the above is the content of assembly.dll, take a look at the
next IR console output:

>>> require "assembly.dll"
=> true
>>> p = Printer::PrintValue.new { |x| puts x }
=> Printer+PrintValue
>>> p("dsfs")
=> nil
>>> d = Printer::PrintValue.new { |x| puts x }
=> Printer+PrintValue
>>> d("dsfd")
:0: undefined method `d' for main:Object (NoMethodError)

Why does p work and d doesn't?

BTW, I see that delegates are converted to something called LightLambda.
What is that?

Many thanks!
Follow me: http://twitter.com/ironshay
Posted via http://www.ruby-forum.com/.

More information about the Ironruby-core mailing list