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
770
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
650
Apple HIG 正式名称クイズ結果発表 / HIG Quiz Result
usamik26
0
190
ゆめみ大技林製作委員会の立ち上げの話 / daigirin project
usamik26
0
340
@ViewLoadingプロパティラッパの紹介と自前で実装する方法 / @ViewLoading property wrapper implementation
usamik26
0
490
これからUICollectionViewを実践活用する人のためのガイド / Guide to UICollectionView
usamik26
1
760
Xcodeとの最近の付き合い方のはなし / Approach To Xcode
usamik26
2
680
UICollectionView Compositional Layout
usamik26
0
800
Coding Swift with Visual Studio Code and Docker
usamik26
0
520
Swift Extension for Visual Studio Code
usamik26
2
1.1k
Other Decks in Programming
See All in Programming
Laravel Boost 超入門
fire_arlo
2
170
Nuances on Kubernetes - RubyConf Taiwan 2025
envek
0
220
詳解!defer panic recover のしくみ / Understanding defer, panic, and recover
convto
0
210
実用的なGOCACHEPROG実装をするために / golang.tokyo #40
mazrean
1
120
Go言語での実装を通して学ぶLLMファインチューニングの仕組み / fukuokago22-llm-peft
monochromegane
0
110
Kiroで始めるAI-DLC
kaonash
2
490
Namespace and Its Future
tagomoris
6
670
MCPでVibe Working。そして、結局はContext Eng(略)/ Working with Vibe on MCP And Context Eng
rkaga
3
230
サイトを作ったらNFCタグキーホルダーを爆速で作れ!
yuukis
0
740
開発チーム・開発組織の設計改善スキルの向上
masuda220
PRO
17
9.5k
旅行プランAIエージェント開発の裏側
ippo012
1
570
時間軸から考えるTerraformを使う理由と留意点
fufuhu
7
1.3k
Featured
See All Featured
Embracing the Ebb and Flow
colly
87
4.8k
Gamification - CAS2011
davidbonilla
81
5.4k
Building Better People: How to give real-time feedback that sticks.
wjessup
368
19k
Scaling GitHub
holman
463
140k
The Art of Programming - Codeland 2020
erikaheidi
55
13k
Fireside Chat
paigeccino
39
3.6k
How STYLIGHT went responsive
nonsquared
100
5.8k
Documentation Writing (for coders)
carmenintech
73
5k
What’s in a name? Adding method to the madness
productmarketing
PRO
23
3.6k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
46
7.6k
A designer walks into a library…
pauljervisheath
207
24k
VelocityConf: Rendering Performance Case Studies
addyosmani
332
24k
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