Question on some code from ironrubymvc


#1

Hi
While working on the code for a ironrubymvc i came across the following
code

controllerRubyClass.EnumerateMethods((_, symbolId, __) =>
{
if
(String.Equals(symbolId, actionName,

StringComparison.OrdinalIgnoreCase))
{

controllerRubyMethodName = symbolId;
return
true;
}
return
false;
});

The tidbit I find interesting is the _ and the __ in the lambda. Is that
an
equivalent for null or does it something else?

Met vriendelijke groeten - Best regards - Salutations
Ivan Porto C.
GSM: +32.486.787.582
Blog: http://flanders.co.nz
Twitter: http://twitter.com/casualjim


#2

Cool! I didn’t know you could do this.

It’s just a placeholder when you don’t care about that arg. Very
functional.


#3

_ and __ are just normal local variables (parameters) scoped to the
lambda.

Tomas

From: removed_email_address@domain.invalid
[mailto:removed_email_address@domain.invalid] On Behalf Of Andrew P.
Sent: Thursday, January 29, 2009 2:06 PM
To: removed_email_address@domain.invalid
Subject: Re: [Ironruby-core] question on some code from ironrubymvc

Cool! I didn’t know you could do this.

It’s just a placeholder when you don’t care about that arg. Very
functional.
On Thu, Jan 29, 2009 at 1:43 PM, Ivan Porto C.
<removed_email_address@domain.invalidmailto:removed_email_address@domain.invalid> wrote:
Hi

While working on the code for a ironrubymvc i came across the following
code

controllerRubyClass.EnumerateMethods((_, symbolId, __) =>
{
if
(String.Equals(symbolId, actionName,
StringComparison.OrdinalIgnoreCase))
{
controllerRubyMethodName
= symbolId;
return
true;
}
return
false;
});

The tidbit I find interesting is the _ and the __ in the lambda. Is that
an equivalent for null or does it something else?

Met vriendelijke groeten - Best regards - Salutations
Ivan Porto C.
GSM: +32.486.787.582
Blog: http://flanders.co.nzhttp://flanders.co.nz/
Twitter: http://twitter.com/casualjim