From: alxtskrnk@... Date: 2015-12-28T16:36:07+00:00 Subject: [ruby-core:72558] [Ruby trunk - Feature #11782] String#+@ and String#-@ Issue #11782 has been updated by bug hit. What is primary use case for `-'string'`? I initially though it was to be a shorthand for `'string'.freeze`, avoiding allocation (due to special compiler support), producing an interned frozen string. But it does a dup, so does `-'string'` lack compiler support, thus first allocating a normal string then duping and freezing a copy which is not interned? So instead of 0 allocations (`'string'.freeze`) you get 2 (`-'string'`)? ---------------------------------------- Feature #11782: String#+@ and String#-@ https://bugs.ruby-lang.org/issues/11782#change-55817 * Author: Koichi Sasada * Status: Assigned * Priority: Normal * Assignee: Yukihiro Matsumoto ---------------------------------------- Matz said > In fact, my best choice is introducing `String#+` that returns a mutable copy of a string. [ruby-core:71879] [Ruby trunk - Bug #11759] So that this is a ticket for that. I'll commit it ASAP to check this methods before 2.3. Specification: * `+'foo'` returns modifiable string. * `-'foo'` returns frozen string (because wasters will freeze below 0 degree in Celsius). -- https://bugs.ruby-lang.org/ Unsubscribe: