Actions
Feature #15606
closedPrecedence of -@ and +@
Feature #15606:
Precedence of -@ and +@
Status:
Feedback
Assignee:
-
Target version:
-
Description
-@
and +@
seem to have issues with method chaining:
i = 5
-i.negative?
# NoMethodError (undefined method `-@' for false:FalseClass)
here's another example:
# frozen_string_literal: true
+'foo'.upcase!
# FrozenError (can't modify frozen String)
I know that I can fix this by adding parentheses, i.e. (-i).negative?
and (+'foo').upcase!
but it feels cumbersome.
Shouldn't the above work out of the box?
Unless I'm missing a crucial use case, the precedence for -@
and +@
should be changed.
Actions