Actions
Feature #8765
closedLiteral for symbol with interpolation
Feature #8765:
Literal for symbol with interpolation
Status:
Feedback
Assignee:
-
Target version:
-
Description
Actions
Added by sawa (Tsuyoshi Sawada) about 13 years ago. Updated about 13 years ago.
Description
Do you need this in an actual program? There is %q and %Q because there is '' and "", and that's because interpolation in Strings is very frequent. Interpolation for Symbols is very rare, as far as I know.
=begin
There are :" " and :' ' notations, whose existence indicate that symbol literals with and without interpolation are used. A typical use case for symbol literal is to create symbols from a list of words with a common prefix. For example, you may have a list of words
and may want to create out of it a list of symbols with a common prefix:
which, by the proposed syntax, can be created as:
=end
On Sat, Aug 10, 2013 at 10:59:24PM +0900, sawa (Tsuyoshi Sawada) wrote:
Issue #8765 has been reported by sawa (Tsuyoshi Sawada).
Feature #8765: Literal for symbol with interpolation
https://bugs.ruby-lang.org/issues/8765Author: sawa (Tsuyoshi Sawada)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:=begin
I propose a symbol literal%Swith interpolationThe conventional
:""literal looks as if it is a unary operator to a string. Since there are both%qand%Qliterals for string, I don't see any reason why symbols only have%s.
irb(main):001:0> RUBY_VERSION
=> "2.0.0"
irb(main):002:0> foo = 3
=> 3
irb(main):003:0> %i{#{foo}}
=> [:"#{foo}"]
irb(main):004:0> %I{#{foo}}
=> [:"3"]
irb(main):005:0>
--
Aaron Patterson
http://tenderlovemaking.com/
tenderlovemaking
What is your intention?
-1 here