How to pass parameters to a Func
So i've made this function. I want to add paramters to it but i just can't figure it out
17 Replies
It's a
Func
with one generic parameter, which defines the return type
It has no parameters
If you want to add them... add themUnknown User•11mo ago
Message Not Public
Sign In & Join Server To View
Func<int, int, bool> func = (intA, intB) => true;
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
Put some generic parameters before the one you already did yeah
Last one is the return type
thank you all. I didn't know you have to put the parameter name between the 2 brackets
btw is there any way to also pass a value to the parameter like that?
I think you will need to type it
(int foo = 0) => { ... }
And at that point might as well use a var
I think it's a fairly new addition to the language, thoughYou can specify return types for anonymous lambdas?
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
Yeah I knew it was implicit i just didn’t know you could go string (int foo = 0) =>…
You can, yeah
Angius
REPL Result: Success
Result: string
Compile: 467.697ms | Execution: 73.448ms | React with ❌ to remove this embed.
That’s cool as hell
Learn something new everyday
Great. 👍