Project

General

Profile

Actions

Feature #17724

closed

Make the pin operator support instance/class/global variables

Added by jnchito (Junichi Ito) about 3 years ago. Updated almost 3 years ago.

Status:
Closed
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

Like0
Like0Like0Like0Like0Like0Like0