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
Swift Weekly 11/1
Search
Johnlin
November 01, 2016
Programming
1
84
Swift Weekly 11/1
Johnlin
November 01, 2016
Tweet
Share
More Decks by Johnlin
See All by Johnlin
用 MLIR 實作 一個 Ruby IR (intermediate representation)
johnlinvc
0
49
Unearth Ruby builtin Gems 發掘 Ruby 的內建 Gems
johnlinvc
0
200
Ruby 型別檢查工具簡介
johnlinvc
0
400
Swift Actor 實作探索
johnlinvc
0
130
用 mruby 來寫跨平台工具
johnlinvc
0
56
Actor model 簡介
johnlinvc
0
160
一起玩 Helm 3
johnlinvc
1
100
為什麼 App 卡卡的
johnlinvc
2
1.1k
如何使用 byebug 來除錯 Ruby 程式
johnlinvc
0
160
Other Decks in Programming
See All in Programming
Kaigi on Rails 2024 〜運営の裏側〜
krpk1900
1
220
Creating a Free Video Ad Network on the Edge
mizoguchicoji
0
120
Remix on Hono on Cloudflare Workers
yusukebe
1
290
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
100
Flutterを言い訳にしない!アプリの使い心地改善テクニック5選🔥
kno3a87
1
180
みんなでプロポーザルを書いてみた
yuriko1211
0
260
Jakarta EE meets AI
ivargrimstad
0
560
シェーダーで魅せるMapLibreの動的ラスタータイル
satoshi7190
1
480
Why Jakarta EE Matters to Spring - and Vice Versa
ivargrimstad
0
1.1k
Nurturing OpenJDK distribution: Eclipse Temurin Success History and plan
ivargrimstad
0
920
Figma Dev Modeで変わる!Flutterの開発体験
watanave
0
130
Snowflake x dbtで作るセキュアでアジャイルなデータ基盤
tsoshiro
2
520
Featured
See All Featured
A better future with KSS
kneath
238
17k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
Designing Experiences People Love
moore
138
23k
A Tale of Four Properties
chriscoyier
156
23k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
42
9.2k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
31
2.7k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
250
21k
The Language of Interfaces
destraynor
154
24k
Building Better People: How to give real-time feedback that sticks.
wjessup
364
19k
Embracing the Ebb and Flow
colly
84
4.5k
Transcript
Swift पใ 11/1 John Lin @johnlinvc
From the core • Swift 3.0.1 GM • ࢧԉߋଟత Ubuntu
൛ຊ • Server API Project
Swift 3.0.1 GM • แؚࡏ Xcode 8.1 㚎 • https://developer.apple.com/library/content/
releasenotes/DeveloperTools/RN-Xcode/ Introduction.html
ࢧԉߋଟత Ubuntu ൛ຊ • աڈࢧԉ • 14.04 • 15.10 •
৽⃧ • 16.04 • 16.10
Server API Project • ਪಈލฏత Server Side ጯ༻ɻ • ሡ࿏҆શ૬᮫త
API Ҡ২౸ Swift ɼ ࠶ෆ༻ґ ↳֎෦త C ఔࣜݿɻ • ෆ။แؚߴ֊త Server ᐽՍɻ • ݱࡏతඪੋݐཱҰݸᘐཱత݅ɼᏈԿ࠶ ܾఆཁෆཁ㚎ݐɻ
Server API workgroup • ֩৺һแؚ Chris Bailey (@seabaylea, IBM Kitura),
Logan Wright (@LoganWright, Vapor), Paulo Faria (@paulofaria, Zewo), Steve Algernon (@salgernon, Apple) • ૬᮫ऀ(stakeholder): ଟਓɼཁᚙPR बՄҎᙛ૬᮫ऀ • ྲྀఔ: API ఏҊ -> ֩৺/૬᮫ऀධ-> Evolution ධ -> ։ᚙ -> ᚙ -> ༻ -> ճᰶ
Evolution • SE-0141 ༻ @available ိඪࣔ Swift ൛ຊ • SE-0142
༻where ိݶ੍ associated types • (佀ճ) SE-0144 Ҹڐ༻ $ ᙛ࡞ identifier
SE-0141 ༻ @available ိඪࣔ Swift ൛ຊ • ݱࡏཁᒾҰ Swift ൛ຊೳ༻
#if swift(>=3.0) Ṝछڊ ूɻ • ະိՄҎ༻ @available(swift 3) ိએࠂՄ༻త swift ൛ ຊɻ • ՄҎ༻ @available(swift, obsoleted: 3.1) ိએࠂະိ ။ኑআɻ • ڊूతࠩҟᴍࡏෆधཁॏ৽ฤᩄɻ
SE-0142 ༻where ိݶ੍ associated types • ՄҎݶ੍ associated type ೭ؒత᮫࿆ੑ
protocol Sequence { associatedtype Iterator : IteratorProtocol associatedtype SubSequence : Sequence where SubSequence.Iterator.Element == Iterator.Element }
(佀ճ) SE-0144 Ҹڐ༻ $ ᙛ࡞ identifier • աڈ༗Ұݸ Bug ੋՄҎ༻ᄸҰݸ
$ ᥒᙛ၏ identifier • ॴҎग़ݱྃҰݸ Lib ڣ၏ dollar ՄҎ၏Ұࠣ Functional తࣄɼ૾ੋ map/reduce • ޙိଞ၇Ṝݸ bug मྃɼୠ༗ਓबෆ։৺ྃ • ࠷ޙେՈܾఆෆೳҝྃҰݸ Lib swift Ꮣಘෳᯑ
Community • ᔟܕ Range ԋࢉ๏ https://oleb.net/blog/2016/10/ generic-range-algorithms/ • TouchBar API
https://developer.apple.com/macos/ touch-bar/
ᔟܕ Range ԋࢉ๏ • Swift 3 ༗ၷछ range • Range
a..<b ෆแؚ b • CloseRange a…b แؚ b • ࡏଞ၇೭ؒෆೳޓ૬
Range 㚎ᬋػᏐࣈ func random(from range: Range<Int>) -> Int { let
distance = range.upperBound - range.lowerBound let rnd = arc4random_uniform(UInt32(distance)) return range.lowerBound + Int(rnd) } let random1 = random(from: 1..<10) let random2 = random(from: 1...10) //error
Range 㚎ᬋػᏐࣈ func random(from range: Range<Int>) -> Int { let
distance = range.upperBound - range.lowerBound let rnd = arc4random_uniform(UInt32(distance)) return range.lowerBound + Int(rnd) } func random(from range: ClosedRange<Int>) -> Int { let distance = range.upperBound - range.lowerBound let rnd = arc4random_uniform(UInt32(distance)) return range.lowerBound + Int(rnd) } let random1 = random(from: 1..<10) let random2 = random(from: 1...10)
Ұݸ๏ extension RandomAccessCollection { func random() -> Iterator.Element? { guard
count > 0 else { return nil } let offset = arc4random_uniform(numericCast(count)) let i = index(startIndex, offsetBy: numericCast(offset)) return self[i] } } (1..<10).random() (1...20).random() ["a","b","c","d"].random()