Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
How to specify `frozen_string_literal: true`
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Kazuhiro NISHIYAMA
September 19, 2017
Technology
480
1
Share
How to specify `frozen_string_literal: true`
RubyKaigi 2017 の LT での発表資料です。
Kazuhiro NISHIYAMA
September 19, 2017
More Decks by Kazuhiro NISHIYAMA
See All by Kazuhiro NISHIYAMA
Headscale + Tailscale に移行中
znz
0
40
Ruby on Rails と私
znz
0
59
riscv64.rubyci.org internal
znz
0
49
Rubyの日本語リファレンスマニュアルの現在と未来
znz
0
97
devise-two-factorを4.xから5.xに上げた話
znz
0
390
docs.ruby-lang.org/ja/ の生成方法を変えた
znz
0
110
Ubuntuのriscv64版をqemuで動かした
znz
0
130
lilo.linux.or.jpをbusterからbullseyeに上げた
znz
0
130
小規模個人アプリをRails 7.xにバージョンアップした話
znz
0
130
Other Decks in Technology
See All in Technology
組織的なAI活用を阻む 最大のハードルは コンテキストデザインだった
ixbox
1
450
AIにより大幅に強化された AWS Transform Customを触ってみる
0air
0
310
JAWS DAYS 2026でAIの「もやっと」感が解消された話
smt7174
1
130
マルチモーダル非構造データとの闘い
shibuiwilliam
1
180
20260326_AIDD事例紹介_ULSC.pdf
findy_eventslides
0
520
VSCode中心だった自分がターミナル沼に入門した話
sanogemaru
0
920
OPENLOGI Company Profile for engineer
hr01
1
62k
2026-04-02 IBM Bobオンボーディング入門
yutanonaka
0
200
Even G2 クイックスタートガイド(日本語版)
vrshinobi1
0
200
「決め方」の渡し方 / How to hand over the "decision-making process"
pauli
7
1.2k
ASTのGitHub CopilotとCopilot CLIの現在地をお話しします/How AST Operates GitHub Copilot and Copilot CLI
aeonpeople
1
120
「活動」は激変する。「ベース」は変わらない ~ 4つの軸で捉える_AI時代ソフトウェア開発マネジメント
sentokun
0
150
Featured
See All Featured
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
150
Believing is Seeing
oripsolob
1
100
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.4k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
2
1k
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
64
54k
GitHub's CSS Performance
jonrohan
1032
470k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Are puppies a ranking factor?
jonoalderson
1
3.2k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
250
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
55k
Transcript
How to specify frozen_string_literal: true Kazuhiro NISHIYAMA RubyKaigi 2017 LT
2017/09/19 Powered by Rabbit 2.2.1
self.introduce One of Ruby committers Twitter, GitHub: @znz 1/12
What’s frozen_string_literal magic comment Specify string literals are frozen or
not per fle Frozen string literals are faster Generate less objects Reduce GC 2/12
Example After coding if exist example: # -*- coding: utf-8
-*- # frozen_string_literal: true p ''.frozen? #=> true 3/12
Past release Add frozen_string_literal: false for almost *.rb fles when
Ruby 2.3.0 For compatibility with --enable=frozen-string- literal command line option of ruby 4/12
Changes in this year Recent Ruby programs tend to specify
true, but ruby standard libraries are false. So I changed to frozen_string_literal: true in some fles which assigned to no maintainer in doc/ maintainers.rdoc. 5/12
Review points before change Almost RuntimeError: can't modify frozen String
points are: String#<< bang methods (e.g. String#sub!) 6/12
Overlooked modifcation IO#read(length, out_buffer) this buffer is overlooked 7/12
Find modifed string literal --debug=frozen-string-literal command line option is very
useful examples: ruby --debug=frozen-string-literal test.rb make test-all TESTS='-v base64' RUBYOPT=--debug=frozen-string-literal 8/12
Tests --debug=frozen-string-literal needs to run codes. So tests are very
important. 9/12
No change if can’t If no tests, there is no
need to forcibly change it. I think working codes are useful than broken faster codes. 10/12
mkmf.rb mkmf.rb has many tests But mkmf.rb is too complex
to me in a short time So I remain false 11/12
Conclusion No tests may overlook modifcations Use frozen_string_literal: true if
you can You can use frozen_string_literal: false in some cases for compatibility for --enable=frozen- string-literal 12/12 Powered by Rabbit 2.2.1