Project

General

Profile

Actions

Feature #4877

closed

Unify Variable Expansion within Strings

Added by lazaridis.com (Lazaridis Ilias) over 13 years ago. Updated over 13 years ago.

Status:
Rejected
Target version:
-
[ruby-core:37071]

Description

class VarTester
$g = "global"
@@c = "class"

def f
"function"
end

def initialize
@i = "instance"
l = "local"
puts "#$g #@@c #@i #l #f #{l} #{f}"
end
end

VarTester.new

#=> global class instance #l #f local function

=== User Context ===

3 variable types (Class- instance- and global) can be expanded by prefixing a single char ("#") (without the need to add "{}").

This should be enabled for local vars and ideally for functions, too (at least the attr accessors).

=== Pro ===

  • consistent expansion of all variable types via "#"
  • reduced typing (use of {} is optional)
  • increased readability of strings which contain many variables.

=== Contra ===

?

=== Compatibility ===

This would break slightly existent behaviour:

existent '#text' within strings would be expanded (should be a rare case)

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0