< :前の番号
^ :番号順リスト
> :次の番号
P :前の記事(スレッド移動)
N :次の記事(スレッド移動)
|<:前のスレッド
>|:次のスレッド
^ :返事先
_:自分への返事
>:同じ返事先を持つ記事(前)
<:同じ返事先を持つ記事(後)
---:分割してスレッド表示、再表示
| :分割して(縦)スレッド表示、再表示
~ :スレッドのフレーム消去
.:インデックス
..:インデックスのインデックス
Issue #15927 has been updated by sawa (Tsuyoshi Sawada).
> My argument for this feature is that String#gsub() and family works with string keys if given a Hash
That is because they replace substrings. The argument cannot be applied to string format, in which what is replaced is fields. Since fields are names, it makes more sense to express them as symbols.
> Also, I don't like having to symbolize keys in strings unnecessarily
Field names should usually be fixed. They are not arbitrarily dynamically created. I do not think you need to worry about GC.
----------------------------------------
Feature #15927: Allow string keys to be used for String#% and sprintf methods
https://bugs.ruby-lang.org/issues/15927#change-78606
* Author: luke-gru (Luke Gruber)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
Right now, in the methods sprintf() and String#%, only symbol keys can be used for named interpolation. For example (from the example documentation):
"foo = %{foo}" % { :foo => 'bar' } #=> "foo = bar"
String keys do not work like this:
"foo = %{foo}" % { 'foo' => 'bar' } #=> raises KeyError
I think string keys should work just the same as symbol keys here.
I've created a PR on github for this, perhaps misguidedly, but if can be found here: https://github.com/ruby/ruby/pull/2238
My argument for this feature is that String#gsub() and family works with string keys if given a Hash, for example:
"chocolate ice cream".gsub(/\bc/, { 'c' => 'C' }) #=> 'Chocolate ice Cream'
Also, I don't like having to symbolize keys in strings unnecessarily, but maybe that just goes back to when
Ruby couldn't GC some symbols.
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>