Issue #15896 has been updated by shevegen (Robert A. Heiler).


I agree with benoit and jeremy, also in regards to the use case description; I
also think that even speed/cache considerations aside, matz possibly may 
consider the proposal to not fit into/to class Symbol. It is actually already
awesome that class Symbol can be modified like this :) - I am not sure if it
is required to add it to class Symbol by default. I can understand it somewhat,
but I think what benoit wrote is true - it may be better to be conservative 
here and keep Symbols and Strings distinct. (See what matz wrote about the
origin of Symbols for ruby).

----------------------------------------
Feature #15896: Symbol#+
https://bugs.ruby-lang.org/issues/15896#change-78319

* Author: zeus (Zeus 81)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
I've made this today
``` ruby
class Symbol
  @@cache_add = Hash.new {|h1,k1| h1[k1] = Hash.new {|h2,k2| h2[k2] = :"#{k1}#{k2}"}}
  def +(s) @@cache_add[self][s] end
end

:abc + :def
# => :abcdef
```
I thought it was so awesome it should become standard.



-- 
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>