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
730
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
550
Apple HIG 正式名称クイズ結果発表 / HIG Quiz Result
usamik26
0
130
ゆめみ大技林製作委員会の立ち上げの話 / daigirin project
usamik26
0
290
@ViewLoadingプロパティラッパの紹介と自前で実装する方法 / @ViewLoading property wrapper implementation
usamik26
0
440
これからUICollectionViewを実践活用する人のためのガイド / Guide to UICollectionView
usamik26
1
700
Xcodeとの最近の付き合い方のはなし / Approach To Xcode
usamik26
2
630
UICollectionView Compositional Layout
usamik26
0
700
Coding Swift with Visual Studio Code and Docker
usamik26
0
460
Swift Extension for Visual Studio Code
usamik26
2
940
Other Decks in Programming
See All in Programming
数十万行のプロジェクトを Scala 2から3に完全移行した
xuwei_k
0
350
非ブラウザランタイムとWeb標準 / Non-Browser Runtimes and Web Standards
petamoriken
0
120
Go の GC の不得意な部分を克服したい
taiyow
3
850
Beyond ORM
77web
9
1.2k
Итераторы в Go 1.23: зачем они нужны, как использовать, и насколько они быстрые?
lamodatech
0
980
コンテナをたくさん詰め込んだシステムとランタイムの変化
makihiro
1
150
これでLambdaが不要に?!Step FunctionsのJSONata対応について
iwatatomoya
2
3.8k
Fibonacci Function Gallery - Part 1
philipschwarz
PRO
0
230
Semantic Kernelのネイティブプラグインで知識拡張をしてみる
tomokusaba
0
180
Spatial Rendering for Apple Vision Pro
warrenm
0
160
Amazon S3 NYJavaSIG 2024-12-12
sullis
0
110
Monixと常駐プログラムの勘どころ / Scalaわいわい勉強会 #4
stoneream
0
290
Featured
See All Featured
Embracing the Ebb and Flow
colly
84
4.5k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
180
[RailsConf 2023] Rails as a piece of cake
palkan
53
5.1k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
45
2.2k
Building Applications with DynamoDB
mza
91
6.1k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.6k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
RailsConf 2023
tenderlove
29
940
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
32
2.7k
Making Projects Easy
brettharned
116
6k
The Cult of Friendly URLs
andyhume
78
6.1k
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