Issue #15896 has been updated by Eregon (Benoit Daloze).


FWIW, there is no need for a cache, since Symbol are interned (and an explicit cache would leak memory).

I think Symbols are generally different than Strings, so #+ feels a bit out of place for me here.
Can you show a realistic use case?

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

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