Project

General

Profile

Actions

Feature #12096

closed

New notation for instance variables and class variables

Added by sawa (Tsuyoshi Sawada) about 8 years ago. Updated almost 5 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:73910]

Description

In order to create symbols that include non-word characters, we have the :'...' notation:

:'foo-bar'
:"foo-bar"

What about extending this notation to instance variables and class variables? The use case is to solve the problems raised in #12046, #11167, #10720. There, the problem was that, even though we can have methods like foo? or symbols like :foo?, we cannot have corresponding instance variables. My proposal is to introduce a similar notation for instance variables:

@'foo?'
@"foo?"

I can't think of a similar use case for class variables, but there is no reason to make class variables to behave different from instance variables more than necessary, so there can also be the corresponding notation for class variables:

@@'foo?'
@@"foo?"

Right now, these notations raise syntax errors, so I don't think it conflicts (raises ambiguity) with the existing syntax.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0