Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add method to Safeable to map null to a particular value #202

Open
dalewking opened this issue Apr 20, 2023 · 0 comments
Open

Add method to Safeable to map null to a particular value #202

dalewking opened this issue Apr 20, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@dalewking
Copy link

When encountering a null value for Safeable often you just want to map that to one of the existing enum values and one can do that in the accessing code with Elvis operator and perhaps some added parentheses, but it would seem to me that it would improve readability if Safeable had a method like:

   fun valueOrElse(defaultValue: T) = value ?: defaultValue
@Alex009 Alex009 added the enhancement New feature or request label Apr 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants