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
490
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
Rubyの配布パッケージの変遷
znz
0
21
Headscale + Tailscale に移行中
znz
0
63
Ruby on Rails と私
znz
0
76
riscv64.rubyci.org internal
znz
0
58
Rubyの日本語リファレンスマニュアルの現在と未来
znz
0
110
devise-two-factorを4.xから5.xに上げた話
znz
0
420
docs.ruby-lang.org/ja/ の生成方法を変えた
znz
0
110
Ubuntuのriscv64版をqemuで動かした
znz
0
140
lilo.linux.or.jpをbusterからbullseyeに上げた
znz
0
140
Other Decks in Technology
See All in Technology
2026TECHFRESH畢業分享會 - 原生還是跨平台? App 開發踩坑實錄
line_developers_tw
PRO
0
1.4k
10年間のブログ発信を振り返って見えたWebアプリケーションエンジニアとしての軌跡
stefafafan
0
170
徹底討論!ECS vs EKS!
daitak
3
1.1k
Comment regagner la souveraineté de vos données tout en étant payé grâce à Nostr !
rlifchitz
0
110
Android の公式 Skill / Android skills
yanzm
0
160
ザ・データベース、MySQL ~ OSC 2026 Sendai ~
sakaik
0
150
AI時代のコスト管理を考えよう〜明日から使える実践AWSノウハウ~
yoshimi0227
0
550
気軽に使える"情報のハブ"としてのNotion活用 〜フロー情報の集積点 と、 Claude Code × Notion AI〜
syucream
1
160
“詰む”前に仕組みを作れ 〜技術の波に溺れないためのキャッチアップ術〜
takasyou
4
610
脱SaaS!FDEを支えるプロビジョニングと分離設計
knih
0
250
螺旋型キャリアの生存戦略 / kinoko-conf2026
rakus_dev
0
150
iOS アプリの「これって不具合ですか?」を AI に調べてもらう
miichan
0
110
Featured
See All Featured
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
170
The agentic SEO stack - context over prompts
schlessera
0
820
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.2k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
Thoughts on Productivity
jonyablonski
76
5.2k
Build your cross-platform service in a week with App Engine
jlugia
234
18k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
270
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
340
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
310
Building Applications with DynamoDB
mza
96
7.1k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
950
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