❔ what is difference between _ and ()?
I have following in constuctor:
the first one will be executed
second one will be skipped
why?
5 Replies
hm, second one will be called if I call command again
interesting! It doesn't run in constructor but it can be runned directly
ah okay! thanks
_
is a discard
So () => foo
is a parameterless lambda
While _ => foo
is a lambda with one parameter, but you don't need it so you discard it
Similarly, (_, _) => foo
is a lambda with two params, both discarded
Etcthats why task wouldn't be executed in constructor?
Seeing how the version with a parameter is supposed to get a cancellation token, and it gets discarded instead... possibly
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.