Frozen String Literal

Episode #496 by Teacher's Avatar David Kimura

Summary

In this episode, we're going to look at the magic comment frozen_literal_string and what it does. We're going to look at various behaviors and migration paths to prepare your application for future versions of Ruby.
rails ruby strings 9:47

Chapters

  • Introduction (0:00)
  • What is the frozen string literal? (1:22)
  • Ruby 3.4 (1:53)
  • Making an array (2:31)
  • String.new (3:11)
  • +"" (3:21)
  • object_id (3:35)
  • Talking about speed (4:37)
  • Memory allocation (5:04)
  • frozen_string_literal in Ruby 3.4 (5:26)
  • Seeing this in an example app (5:52)
  • Enabling warnings in Rails (6:22)
  • Thinking about future upgrades (6:54)
  • Additional flags (8:02)
  • Interpolation (8:54)
  • Final thoughts (9:15)
Student & Teacher
$ 9 /mo

Valid School Email Required

Same Access as Pro

Subscribe Now
Pro Monthly
$ 19 /mo

Access to Pro Episodes

Invite to Slack Channel

Priority Suggestions

Ad Free

Subscribe Now
Pro Annual
$ 190 /yr

Access to Pro Episodes

Invite to Slack Channel

Priority Suggestions

Ad Free

Subscribe Now
Teams
$ 57 /mo

3 Users Minimum

$19.00 / user / month

Same Access as Pro

Subscribe to Teams