Project

General

Profile

Actions

Feature #15606

closed

Precedence of -@ and +@

Added by sos4nt (Stefan Schüßler) about 5 years ago. Updated about 5 years ago.

Status:
Feedback
Assignee:
-
Target version:
-
[ruby-core:91556]

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

Also available in: Atom PDF

Like0
Like0Like0Like0Like0