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
580
Apple HIG 正式名称クイズ結果発表 / HIG Quiz Result
usamik26
0
140
ゆめみ大技林製作委員会の立ち上げの話 / daigirin project
usamik26
0
300
@ViewLoadingプロパティラッパの紹介と自前で実装する方法 / @ViewLoading property wrapper implementation
usamik26
0
450
これからUICollectionViewを実践活用する人のためのガイド / Guide to UICollectionView
usamik26
1
710
Xcodeとの最近の付き合い方のはなし / Approach To Xcode
usamik26
2
640
UICollectionView Compositional Layout
usamik26
0
720
Coding Swift with Visual Studio Code and Docker
usamik26
0
480
Swift Extension for Visual Studio Code
usamik26
2
970
Other Decks in Programming
See All in Programming
AWS Organizations で実現する、 マルチ AWS アカウントのルートユーザー管理からの脱却
atpons
0
130
ペアーズでの、Langfuseを中心とした評価ドリブンなリリースサイクルのご紹介
fukubaka0825
2
300
CI改善もDatadogとともに
taumu
0
110
Bedrock Agentsレスポンス解析によるAgentのOps
licux
2
720
社内フレームワークとその依存性解決 / in-house framework and its dependency management
vvakame
1
550
Unity Android XR入門
sakutama_11
0
140
XStateを用いた堅牢なReact Components設計~複雑なClient Stateをシンプルに~ @React Tokyo ミートアップ #2
kfurusho
1
770
負債になりにくいCSSをデザイナとつくるには?
fsubal
9
2.3k
2024年のWebフロントエンドのふりかえりと2025年
sakito
1
230
Djangoアプリケーション 運用のリアル 〜問題発生から可視化、最適化への道〜 #pyconshizu
kashewnuts
1
230
WebDriver BiDiとは何なのか
yotahada3
1
140
第3回関東Kaggler会_AtCoderはKaggleの役に立つ
chettub
3
890
Featured
See All Featured
Unsuck your backbone
ammeep
669
57k
Bash Introduction
62gerente
610
210k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
RailsConf 2023
tenderlove
29
1k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
7k
What's in a price? How to price your products and services
michaelherold
244
12k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7.1k
Navigating Team Friction
lara
183
15k
Music & Morning Musume
bryan
46
6.3k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
33
2.8k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
40
2k
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