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
String Interpolation
Search
USAMI Kosuke
November 28, 2016
Programming
0
740
String Interpolation
https://kanmoba.connpass.com/event/45133/
USAMI Kosuke
November 28, 2016
Tweet
Share
More Decks by USAMI Kosuke
See All by USAMI Kosuke
Onsager代数とその周辺 / Onsager algebra tsudoi
usamik26
0
600
Apple HIG 正式名称クイズ結果発表 / HIG Quiz Result
usamik26
0
160
ゆめみ大技林製作委員会の立ち上げの話 / daigirin project
usamik26
0
310
@ViewLoadingプロパティラッパの紹介と自前で実装する方法 / @ViewLoading property wrapper implementation
usamik26
0
460
これからUICollectionViewを実践活用する人のためのガイド / Guide to UICollectionView
usamik26
1
720
Xcodeとの最近の付き合い方のはなし / Approach To Xcode
usamik26
2
650
UICollectionView Compositional Layout
usamik26
0
750
Coding Swift with Visual Studio Code and Docker
usamik26
0
490
Swift Extension for Visual Studio Code
usamik26
2
1k
Other Decks in Programming
See All in Programming
データベースエンジニアの仕事を楽にする。PgAssistantの紹介
nnaka2992
8
3.9k
ニックトレイン登壇資料
ryotakurokawa
0
130
PHPer's Guide to Daemon Crafting Taming and Summoning
uzulla
2
830
The Evolution of Enterprise Java with Jakarta EE 11 and Beyond
ivargrimstad
0
620
Node.js, Deno, Bun 最新動向とその所感について
yosuke_furukawa
PRO
6
3k
PHPUnit 高速化テクニック / PHPUnit Speedup Techniques
pinkumohikan
1
870
ベクトル検索システムの気持ち
monochromegane
28
8.2k
2025/3/18 サービスの成長で生じる幅広いパフォーマンスの問題を、 AIで手軽に解決する
shirahama_x
0
160
マルチアカウント環境での、そこまでがんばらない RI/SP 運用設計
wa6sn
0
220
爆速スッキリ! Rspack 移行の成果と道のり - Muddy Web #11
dora1998
0
140
Functional APIから再考するLangGraphを使う理由
os1ma
4
640
PsySHから紐解くREPLの仕組み
muno92
PRO
1
500
Featured
See All Featured
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
227
22k
Navigating Team Friction
lara
183
15k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.8k
Reflections from 52 weeks, 52 projects
jeffersonlam
349
20k
Become a Pro
speakerdeck
PRO
27
5.2k
Measuring & Analyzing Core Web Vitals
bluesmoon
6
320
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
45
9.5k
Code Reviewing Like a Champion
maltzj
521
39k
Automating Front-end Workflow
addyosmani
1369
200k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
2.1k
Scaling GitHub
holman
459
140k
A Tale of Four Properties
chriscoyier
158
23k
Transcript
Swift String Interpolation USAMI Kosuke Fenrir Inc.
String Interpolation let price = 2 let number = 3
let message = "One cookie: $\(price), \(number) cookies:" + "$\(price * number)."
จࣈྻิؒखܰͰศརͰ͢Ͷ » ͚ͩͲɺϩδοΫ෦ͰΘͳ͍ํ͕͍͍ » URL ͱ͔ΫΤϦͱ͔Ͱආ͚Δ » ݁Ռ͕༧ଌͮ͠Β͍ͨΊ » ͋͘·Ͱɺ͓खܰදࣔ༻ͷػೳͰ͋Δ
จࣈྻิ͕ؒͲͷΑ͏ʹߦΘΕΔ͔ » ExpressibleByStringInterpolation ϓϩτίϧʹઆ໌͕͋Δ » ·ͣɺϦςϥϧ෦ͱิؒ෦ʹׂ͞ΕΔ » ͦΕͧΕͷิؒ෦͕ init(stringInterpolationSegment:) ʹ
͞ΕΔ » ͦΕΒͷ݁Ռ͕ init(stringInterpolation:) ʹ͞ΕΔ
͜Μͳײ͡ let message = String(stringInterpolation: String(stringInterpolationSegment: "One cookie: $"), String(stringInterpolationSegment:
price), String(stringInterpolationSegment: ", "), String(stringInterpolationSegment: number), String(stringInterpolationSegment: " cookies: $"), String(stringInterpolationSegment: price * number), String(stringInterpolationSegment: "."))
ExpressibleByStringInterpolation » ͭ·Γɺ͜ͷϓϩτίϧΛࣗલͰ࣮͢ΕΧελϚΠζͰ͖Δ » ͔࣮͠͠ɺ͜ΕΛ࣮͢Δඞཁ͋·Γͳ͍ʢޙड़ʣ
จࣈྻิؒͷσϑΥϧτͷৼΔ͍ » String.init(describing:) Λฦ͢Α͏࣮͞Ε͍ͯΔ » ͨͩ͠ɺ͍͔ͭ͘ͷϏϧτΠϯܕผ࣮ʢBool ͳͲʣ » ref :
https://github.com/apple/swift/blob/swift-3.0.1- RELEASE/stdlib/public/core/StringInterpolation.swift.gyb
String.init(describing:) » TextOutputStreamable ʹద߹͍ͯͨ͠Β .write(to: s) Λฦ͢ » CustomStringConvertible ʹద߹͍ͯͨ͠Β
.description Λฦ͢ » CustomDebugStringConvertible ʹద߹͍ͯͨ͠ Β .debugDescription Λฦ͢ » ͦΕҎ֎ Swift ඪ४ϥΠϒϥϦ͕ࣗಈੜ͢Δ
ࣗલclassΛจࣈྻิؒʹରԠ͢Δʹ » ExpressibleByStringInterpolation ͡Όͳ͍͍ͯ͘ » ྫ͑ CustomStringConvertible ͷ .description Λ࣮
» ͩ͜ΘΒͳ͍ͳΒɺඪ४·͔ͤͰग़ྗ͞ΕΔ
ͱ͜ΖͰ Swift 4 Ͱɾɾɾ » ExpressibleByStringInterpolation deprecated » SwiftDoc.org
» Deprecated: it will be replaced or redesigned in Swift 4.0. Instead of conforming to 'ExpressibleByStringInterpolation', consider adding an 'init(_:String)'.
Ͳ͏ͳΔͷʁ » Proposal SE-0137 : Avoiding Lock-In to Legacy Protocol
Designs » We know this protocol to be mis-designed and limited, but there's no time to fix it for Swift 3. » ࠶ઃܭ͞ΕΔ༧ఆΒ͍͠ » Ϧςϥϧ෦ͱิؒ෦ʹׂɺͱ͔ buggy ͳײ͡
ࢀߟ » SwiftDoc.org » github.com/apple/swift » Swift ͷ Bool ͷจࣈྻදݱͷݴޠ༷
- ja.stackoverflow.com