Project

General

Profile

Actions

Bug #18246

closed

send does not work for unary ! operator when operator isn't a literal symbol

Added by chucke (Tiago Cardoso) 8 months ago. Updated 8 months ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:105594]

Description

1.send(:+, 1) #=> 2
1.send(:"+", 1) #=> 2
1.send(:-@) #=> -1
1.send(:"-@") #=> -1
false.send(:!@) #=> true
false.send(:"!@") #> 
# undefined method `!@' for false:FalseClass (NoMethodError)
# Did you mean?  !=
               !~

Related issues 1 (0 open1 closed)

Is duplicate of Ruby master - Feature #10463: :~@ and :!@ are not parsed correctlyRejectedmatz (Yukihiro Matsumoto)Actions
Actions #1

Updated by jeremyevans0 (Jeremy Evans) 8 months ago

  • Is duplicate of Feature #10463: :~@ and :!@ are not parsed correctly added

Updated by jeremyevans0 (Jeremy Evans) 8 months ago

  • Status changed from Open to Closed

The method you are looking for is ! and not !@. The reason false.send(:!@) works is that :!@ is parsed as :!, that's why the unquoted version works but the quoted version does not. This was determined to be a feature and not a bug in #10463.

Actions

Also available in: Atom PDF