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


I like .dup and .freeze, more than + and - on class String.

https://ruby-doc.org/core-2.5.0/String.html#method-i-2B-40

The only good thing is that I don't have to use any of these
methods so ultimately I don't have to care either way. :)

As for linters, I assume you refer to rubocop since that is
by far the most common use case I could see, with people
putting things such as:

   FOO = 'foo'.freeze
   BAR = 'bar'.freeze

into files. I wonder if matz thinks that this is a good way;
to me, I always wondered when people do so. Probably 
lint-based development ... should that not be superfluous
with frozen strings now? One comment on top of the file
and avoid all the explicit .freeze calls?

----------------------------------------
Feature #14680: Adding @+ and @- to hash and array
https://bugs.ruby-lang.org/issues/14680#change-71456

* Author: kddeisz (Kevin Deisz)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
Since we have @- and @+ for strings and it's very useful (and reads better than .freeze) I'd like to propose adding the same API to hash and array. Especially with constants, linters are always telling me to freeze them, and I'd like to be able to accomplish that with @-. I've attached the necessary code to make that happen.

---Files--------------------------------
freeze.patch (3.86 KB)


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