It's the 'Dynamic Dictionary' [0]. It's usually called 'parameters' but it's idiomatic in dotnet to name lambda input parameter '_' if don't use it in your expression.
[0] https://github.com/NancyFx/Nancy/wiki/Taking-a-look-at-the-D...
As others have said, it's idiomatic to name a lambda param "_" if you're not using it.
To perhaps clarify a bit, here's what the Hello World example would look like if we added a second route that uses the lambda parameter, and a third route that does something else, and a fourth route that renders a view template.
public SampleModule() {
Get["/"] = _ => "Hello World!";
Get["/hello/{name}"] = p => ("Hello, " + p.name + "!");
Get["/something-complicated"] = _ => {
// complicated stuff happens here
return "OK... we're all done";
};
// A variety of template engines are supported
Get["/my-resume"] = _ => View["resume.cshtml"];
}Unused parameter for lambda function.
Re:Mono 3.2.7 is out
by SideburnsOfDoom on Wednesday February 26, 2014 @02:40PM
(#7307110)
This is the most accurate reply. The expression
Get["/"] = _ => "Hello World!";
is actually of the form a = b;Where "a", i.e. "Get["/"]" is an array-like property (http://msdn.microsoft.com/en-us/library/2549tw02.aspx ) and the "b" value assigned to it is an anonymous function with one parameter, i.e.
_ => "Hello World!"
In Nancy these handlers are of the type Func<dynamic, dynamic> ( http://msdn.microsoft.com/en-us/library/bb549151(v=vs.110).a... ) The parameter could be given any legal name, but an underscore is a convention meaning "I am not using this param".
Re:Mono 3.2.7 is out
by romanovcode on Wednesday February 26, 2014 @02:29PM
(#7307032)
It's dynamic path element.
public SampleModule()
{
Get["/{id:int}"] = _ =>
{
int id = _.id;
return "Parameter ID is: " + id.ToString();
};
}
public SampleModule() { Get["/"] = _ => "Hello World!"; }
[1] http://nancyfx.org/