Skip to content

Fix mix to accept old or new nil values #780

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

Merged
merged 3 commits into from
Sep 13, 2024

Conversation

davekaro
Copy link
Contributor

@davekaro davekaro commented Sep 12, 2024

Fixes #779, but I don't think it's all the way there because it only handles the [String, nil] combo. I don't know the reasons the code changed for mix so much in 0f8d8cb#diff-1379affdd94a5363d3331840af91bc6171dac9338b2f6bd886a0636ac6258a38, so this is more a starting point.

Update: in the second commit I made it work for the other types, but I'm sure there are other approaches to consider.

Comment on lines 29 to 30
else
new
new.nil? ? old : new
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about following the pattern matching style with something like:

case [old, new]
# ...
in [_, nil]
  old
else
  new
end

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the _ was exactly what I was looking for. Thanks!

@joeldrapper joeldrapper merged commit 808ba55 into yippee-fun:main Sep 13, 2024
6 checks passed
@davekaro davekaro deleted the mix-nil branch September 13, 2024 13:06
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.

mix handles nils poorly
3 participants