File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -209,6 +209,7 @@ _305 TILs and counting..._
209209- [ Comparing Arrays In RSpec] ( ruby/comparing-arrays-in-rspec.md )
210210- [ Construct A Constant From A String] ( ruby/construct-a-constant-from-a-string.md )
211211- [ Create an Array of Stringed Numbers] ( ruby/create-an-array-of-stringed-numbers.md )
212+ - [ Defaulting To Frozen String Literals] ( ruby/defaulting-to-frozen-string-literals.md )
212213- [ Destructuring Arrays In Blocks] ( ruby/destructuring-arrays-in-blocks.md )
213214- [ Disassemble Some Codes] ( ruby/disassemble-some-codes.md )
214215- [ Double Splat To Merge Hashes] ( ruby/double-splat-to-merge-hashes.md )
Original file line number Diff line number Diff line change 1+ # Defaulting To Frozen String Literals
2+
3+ > The cold never bothered me anyway.
4+
5+ The release of Ruby 2.2 introduced the ability to freeze string literals,
6+ making them immutable. With the release of Ruby 2.3, strings can be frozen
7+ by default without the use of ` #freeze ` . By adding the following magic
8+ comment at the top of a file
9+
10+ ``` ruby
11+ # frozen_string_literal: true
12+ ```
13+
14+ all string literals will default to frozen. That means that all string
15+ literals in that file are immutable, cannot be modified. This gives the Ruby
16+ interpreter some performance gains due to reduced object allocation.
17+
18+ This is the [ issue] ( https://bugs.ruby-lang.org/issues/11473 ) that introduced
19+ it.
You can’t perform that action at this time.
0 commit comments