Skip to content

Commit

Permalink
language
Browse files Browse the repository at this point in the history
  • Loading branch information
rkh committed Sep 24, 2013
1 parent b3a0769 commit 802e8e0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion articles/06-ruby-2.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Ruby 2.1 introduces the `r` suffix for decimal/rational literals to fix this:
irb(main):002:0> 0.1r * 3
=> (3/10)

### Frozen String Literal
### Frozen String Literals

When you have a string literal in your code, Ruby will create a new string literal every time that line of code is executed. This has to happen, as strings in Ruby are mutable. This is also why symbols are more efficient in many cases. However, symbols are not strings. For instance, if you want to compare some user input to a symbol, you'll either have to convert the symbol to a string or the string to a symbol. This means you either open yourself up to a denial of service attack, as symbols are not garbage collected, or you again end up with an additional string creation.

Expand Down

0 comments on commit 802e8e0

Please sign in to comment.