Issue #10541 has been updated by Brian Hempel.


Recursive Madman wrote:
> Did you also check what character followed those interpolations? e.g. "#{@foo}bar" wouldn't be a candidate for the shorthand, so that shouldn't be counted.

Okay, this time I only counted string interpolations that weren't followed by [A-Za-z_]. Only a few times (757 of 19869, 4%) the regular cannot be replaced its equivalent shorthand.

19,112 of string interpolations were like "#{@ivar}" or "#{$gvar}" or "#{@@cvar}" and could have been represented using shorthand syntax. (Compared to 1,376 actual shorthand interpolations.)

So, when the shorthand syntax could be used, 93.3% of the time the regular syntax was used anyway. The shorthand was only used in 6.7% of the cases where it could have been used. 13.9 times less common.

~~~
17324 "#{@ivar}"
1638  "#{$gvar}"
150   "#{@@cvar}"
~~~

----------------------------------------
misc #10541: Remove shorthand string interpolation syntax
https://bugs.ruby-lang.org/issues/10541#change-50312

* Author: Daniel Morrison
* Status: Open
* Priority: Normal
* Assignee: Yukihiro Matsumoto
* Category: syntax
* Target version: current: 2.2.0
----------------------------------------
I would like to see the shorthand string interpolation syntax, "foo#@bar" deprecated and then removed in 3.0.

My reasons:

1. Most experienced Ruby developers I've talked to don't even know it exists.
2. It has been the cause of real problems. http://status.cloudamqp.com/incidents/vj62pnp62tj9

When a syntax is not widely known and has the potential for problems, I think it makes sense to deprecate and remove. 



-- 
https://bugs.ruby-lang.org/