Does Dart have an identity function? I understand that I can just write, (x) => x
, but it would seem to be slightly easier to understand code if there was something like Function.identity
?
Not in the core libraries (but possibly in some third-party package). It's trivial to make your own generic function:
T identity<T>(T x) => x;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With