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

Using the safe navigation operator with other operators? #705

Open
arempe93 opened this issue Feb 16, 2018 · 2 comments
Open

Using the safe navigation operator with other operators? #705

arempe93 opened this issue Feb 16, 2018 · 2 comments

Comments

@arempe93
Copy link

Recently, I came across this:

do_something if value1 &.!= value2

Which was equal parts very cool and startling.

So I wanted to get community feedback on whether or not it was too obscure to be good style. We can add our findings to the style guide, since there is no guidance on it yet

@marcandre
Copy link
Contributor

My feeling is that these should be highly discouraged for use with comparison operators.

do_something if value1 &.!= value2
# not the same as
do_something unless value1 &.== value2

I personally can't grok either of the above and I have to "unroll" those in my head.

For other operators I am neutral:

ary &.<< elem
foo &.+ bar

@bbatsov
Copy link
Collaborator

bbatsov commented Jun 14, 2020

They all seem somewhat confusing to me, especially the comparison ops. Generally, I find it weird you'd care about a nil check in a comparison anyways.

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

No branches or pull requests

3 participants