Lazy evaluation getOrElseGet pattern Option
Closed this issue · 1 comments
tosun-si commented
Hi.
I am looking for an API with the option pattern for use it in a Angular 5 project.
I have a question, the API doesn't provide a "getOrElseGet" in the pattern Option, with a supplier in parameter (allows a lazy evaluation for the OR case).
For exemple getOrElseGet( () => defaultValue)
Have you planned to add it in a futur release ?
Thanks for your help.
AlexGalays commented
I'm not against adding it :)
I refrained from doing so initially as creating a lambda is not free in JS and probably more costly than most primitives, etc.
By the way, spacelift would be the lib to look at for the up to date Option (and Result) code.
I could probably simply overload the current definition of getOrElse.