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

Return empty string when input is not binary #192

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

NaseeraA
Copy link

No description provided.

Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But why? :)

@NaseeraA
Copy link
Author

The function fails with nil input. Currently, I'm using guards to check for non-nil values before invoking the function.

if  payment_status,
do:  payment_status |> Recase.to_sentence() ,
else:  ""

@sobolevn
Copy link
Member

What's wrong with that? You can pattern match on your own inputs instead. This operation "recase" only makes sense on binary input, not on nil.

@NaseeraA
Copy link
Author

Agreed, you can.

The disadvantage though is that my code is littered with checks preceding each call to recase. An optional default parameter would be great. Alternatively, we could wrap all of our calls to recase internally within our project.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants