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 nullable convert method #21

Closed
tenhobi opened this issue Apr 11, 2023 · 0 comments · Fixed by #34
Closed

Add nullable convert method #21

tenhobi opened this issue Apr 11, 2023 · 0 comments · Fixed by #34
Assignees
Labels
enhancement New feature or request

Comments

@tenhobi
Copy link
Member

tenhobi commented Apr 11, 2023

The convert method returns T, and when a source is null, it returns the whenSourceIsNull value if it is present or an Exception.

While it might be the use case we want, some people might want a less strict method that could return null when the source is null, etc. To make it type-safe, the original convert method should still return T while the new method tryConvert should be created with return type T?.

With spec

Target convert<Source, Target>(Source? model);
Target? tryConvert<Source, Target>(Source? model);
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

Successfully merging a pull request may close this issue.

2 participants