Forum Discussion
The 'right' way to bring a custom function requiring arguments 'inline'
- 1 year ago
p45cal , regarding "in-line" function definition and call: consider Function.Invoke as an alternative. Example:
( ) => 5 // this is our function ( ( ) => 5 )( ) // this is how you call it now Function.Invoke( ( ) => 5, { } ) // alternative way to call our functionI am not aware of any other alternatives. And there is nothing wrong with your current approach. But the fact that you apply it to solve that particular problem (the one with different "_" conflicting each other) does not look like a ... reasonable one in that particular case. The problem is solved by different identifiers, not by "in-line function call".
Thankyou both AlienSx and ZhangKun . I wanted to reply before too much time went by (I'm still exploring your suggestions, reading Ben Gribaudo's Primer (I had already been reading it but hadn't reached Part 21)).
While you have provided good solutions to the specific example given, I'm not yet sure if this will answer my query regarding how to bring 'in-line' a custom function which requires arguments; I'm thinking any custom function, any arguments, not necessarily from the same row/record, perhaps even hard-coded arguments in some cases.
Up until now I've been doing it by enclosing the function in parentheses and passing the argument(s) in parentheses straight after, and I was wondering whether there was a better way.
Maybe after a bit more exploring I'll find that you have in fact answered my question but I didn't want this thread to remain unacknowledged for too long!
p45cal , regarding "in-line" function definition and call: consider Function.Invoke as an alternative. Example:
( ) => 5 // this is our function
( ( ) => 5 )( ) // this is how you call it now
Function.Invoke( ( ) => 5, { } ) // alternative way to call our function
I am not aware of any other alternatives. And there is nothing wrong with your current approach. But the fact that you apply it to solve that particular problem (the one with different "_" conflicting each other) does not look like a ... reasonable one in that particular case. The problem is solved by different identifiers, not by "in-line function call".