mattaylor/elvis

Change conditional access operator `?.` for higher precedence?

geekrelief opened this issue · 1 comments

?. has lower precedence than == https://nim-lang.github.io/Nim/manual.html#syntax-precedence

If we wanted to do something like:

if d?.val == 10:
  echo "foo"

We would need to wrap the expression in parentheses:

if (d?.val) == 10:
  echo "foo"

If we change the operator to .? then this works:

if d.?val == 10:
  echo "foo"

I suggest renaming the operator to .? since dot operators have higher precedence than operators with =.