Project

General

Profile

Actions

Feature #17724

closed

Make the pin operator support instance/class/global variables

Added by jnchito (Junichi Ito) 6 months ago. Updated 2 months ago.

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

Description

When I use pattern match with instance variables, I get an error message like "expecting local variable or method"

@n = 1
case 1
in ^@n
  # ...
end
#=> syntax error, unexpected instance variable, expecting local variable or method (SyntaxError)
#   in ^@n
#       ^~

However using method is not allowed, either.

def n = 1
case 1
in ^n
  # ...
end
#=> n: no such local variable (SyntaxError)

I think the message "expecting local variable or method" is confusing and should be fixed like "expecting local variable."

Actions

Also available in: Atom PDF