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
530
Apple HIG 正式名称クイズ結果発表 / HIG Quiz Result
usamik26
0
110
ゆめみ大技林製作委員会の立ち上げの話 / daigirin project
usamik26
0
280
@ViewLoadingプロパティラッパの紹介と自前で実装する方法 / @ViewLoading property wrapper implementation
usamik26
0
430
これからUICollectionViewを実践活用する人のためのガイド / Guide to UICollectionView
usamik26
1
690
Xcodeとの最近の付き合い方のはなし / Approach To Xcode
usamik26
2
610
UICollectionView Compositional Layout
usamik26
0
680
Coding Swift with Visual Studio Code and Docker
usamik26
0
450
Swift Extension for Visual Studio Code
usamik26
2
910
Other Decks in Programming
See All in Programming
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
100
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
120
광고 소재 심사 과정에 AI를 도입하여 광고 서비스 생산성 향상시키기
kakao
PRO
0
170
Figma Dev Modeで変わる!Flutterの開発体験
watanave
0
140
型付き API リクエストを実現するいくつかの手法とその選択 / Typed API Request
euxn23
8
2.2k
OnlineTestConf: Test Automation Friend or Foe
maaretp
0
110
macOS でできる リアルタイム動画像処理
biacco42
9
2.4k
Tauriでネイティブアプリを作りたい
tsucchinoko
0
370
Creating a Free Video Ad Network on the Edge
mizoguchicoji
0
120
色々なIaCツールを実際に触って比較してみる
iriikeita
0
330
Make Impossible States Impossibleを 意識してReactのPropsを設計しよう
ikumatadokoro
0
210
NSOutlineView何もわからん:( 前編 / I Don't Understand About NSOutlineView :( Pt. 1
usagimaru
0
340
Featured
See All Featured
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
410
Done Done
chrislema
181
16k
4 Signs Your Business is Dying
shpigford
180
21k
How STYLIGHT went responsive
nonsquared
95
5.2k
StorybookのUI Testing Handbookを読んだ
zakiyama
27
5.3k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.4k
Designing the Hi-DPI Web
ddemaree
280
34k
A better future with KSS
kneath
238
17k
Become a Pro
speakerdeck
PRO
25
5k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
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