Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
"奇妙"なSwift
Search
kntk
September 21, 2025
420
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
"奇妙"なSwift
iOSDC2025 day2 LT
kntk
September 21, 2025
Transcript
44 slides
lحົzͳ4XJGU !LOUL J04%$JPTEDB
͡Ίʹ w4XJGUʹଟ͘ͷจ๏ɾݴޠػೳ͕ଘࡏ w໌ࣔతɾײతͰ͋Δ͜ͱʹఆධ
͡Ίʹ w4XJGUʹଟ͘ͷจ๏ɾݴޠػೳ͕ଘࡏ w໌ࣔతɾײతͰ͋Δ͜ͱʹఆධ wͨͩ͠Ԡ༻͢Δͱحົͳίʔυʜ
͡Ίʹ [1, 2][{ _ in }]
ྫ [1, 2][{ _ in }]
ྫ [1, 2][{ _ in }] "SSBZ4MJDF*OU < >
[1, 2][{ _ in }] "SSBZ-JUFSBM ྫจ๏
ྫจ๏ [1, 2][{ _ in }] "SSBZ-JUFSBM 4VCTDSJQU$BMM $MPTVSF
ྫจ๏ [1, 2][{ _ in }] "SSBZ-JUFSBM 4VCTDSJQU$BMM $MPTVSF subscript(_
f: (…) -> Void) -> … {}
ྫจ๏ [1, 2][...] 6OCPVOEFE3BOHF
ྫ3BOHFͱTVCTDSJQU let range: Range<Int> =
let range: Range<Int> = 0..<1 // ..<RangeΛੜ͢Δԋࢉࢠ extension Comparable {
public static func ..< (minimum: Self, maximum: Self) -> Range<Self> {} } ྫ3BOHFͱTVCTDSJQU
ྫ3BOHFͱTVCTDSJQU let range: Range<Int> = 0..<1 print([1, 2][range]) // ArraySlice<Int>([1])
// ..<RangeΛੜ͢Δԋࢉࢠ extension Comparable { public static func ..< (minimum: Self, maximum: Self) -> Range<Self> {} }
ྫ6OCPVOEFE3BOHFͩͱʜ let range: UnboundedRange<Int> = ... print([1, 2][range]) // ArraySlice<Int>([1,
2]) extension Comparable { public static func ... () -> UnboundedRange<Self> {} }
ྫ6OCPVOEFE3BOHFͩͱʜ let range: UnboundedRange<Int> = ... print([1, 2][range]) // ArraySlice<Int>([1,
2]) extension Comparable { public static func ... () -> UnboundedRange<Self> {} 🔴 }
... ྫ6OCPVOEFE3BOHF public typealias UnboundedRange = (UnboundedRange_)->() public enum UnboundedRange_
{ public static postfix func ... (_: UnboundedRange_) -> () { } }
ྫ6OCPVOEFE3BOHF public typealias UnboundedRange = (UnboundedRange_)->() public enum UnboundedRange_ {
public static postfix func ... (_: UnboundedRange_) -> () { } } // ʮ...ʯؔͷࢀরͱͯ͠هड़ [1, 2][...]
ྫ6OCPVOEFE3BOHF public typealias UnboundedRange = (UnboundedRange_)->() public enum UnboundedRange_ {
public static postfix func ... (_: UnboundedRange_) -> () { } } // ʮ...ʯؔͷࢀরͱͯ͠هड़ [1, 2][...] extension Collection { public subscript(x: UnboundedRange) -> SubSequence {} }
ྫ6OCPVOEFE3BOHF public typealias UnboundedRange = (UnboundedRange_)->() public enum UnboundedRange_ {
public static postfix func ... (_: UnboundedRange_) -> () { } } // ΫϩʔδϟʔҾʹೖͬͯ͠·͏ʂ [1, 2][{ _ in }] extension Collection { public subscript(x: UnboundedRange) -> SubSequence {} }
ྫԠ༻ typealias LastIndex = (LastIndex_) -> Void postfix operator ~
enum LastIndex_ { static postfix func ~(_ l: LastIndex_) -> Void {} } extension MutableCollection where Self: BidirectionalCollection { // shorthand of index(before: endIndex) subscript(_ l: LastIndex) -> Element { get { self[index(before: endIndex)] } set { self[index(before: endIndex)] = newValue } } }
ྫԠ༻ typealias LastIndex = (LastIndex_) -> Void postfix operator ~
enum LastIndex_ { static postfix func ~(_ l: LastIndex_) -> Void {} } extension MutableCollection where Self: BidirectionalCollection { // shorthand of index(before: endIndex) subscript(_ l: LastIndex) -> Element { get { self[index(before: endIndex)] } set { self[index(before: endIndex)] = newValue } } } var array = [1, 2, 3] array[~] = 10
ྫ switch Int.random(in: 1..<100) { case { $0.isMultiple(of: 3) }:
print("multiple of 3") case { $0.isMultiple(of: 5) }: print("multiple of 5") default: print("other") } func ~=<T>(evaluate: (T) -> Bool, rhs: T) -> Bool { evaluate(rhs) }
ྫ switch Int.random(in: 1..<100) { case { $0.isMultiple(of: 3) }:
print("multiple of 3") case { $0.isMultiple(of: 5) }: print("multiple of 5") default: print("other") } func ~=<T>(evaluate: (T) -> Bool, rhs: T) -> Bool { evaluate(rhs) }
ྫ switch Int.random(in: 1..<100) { case { $0.isMultiple(of: 3) }:
print("multiple of 3") case { $0.isMultiple(of: 5) }: print("multiple of 5") default: print("other") } func ~=<T>(evaluate: (T) -> Bool, rhs: T) -> Bool { evaluate(rhs) }
ྫύλʔϯϚονϯάԋࢉࢠ switch Int.random(in: 1..<100) { case { $0.isMultiple(of: 3) }:
} switch Int.random(in: 1..<100) { case { $0.isMultiple(of: 3) }: }
ྫύλʔϯϚονϯάԋࢉࢠ switch Int.random(in: 1..<100) { case { $0.isMultiple(of: 3) }:
} { $0.isMultiple(of: 3) } ~= Int.random(in: 1..<100) ίϯύΠϥ෦ͰಡΈସ͑ ˞FOVNͷύλʔϯϚονผ
ྫύλʔϯϚονϯάԋࢉࢠ switch Int.random(in: 1..<100) { case { $0.isMultiple(of: 3) }:
} { $0.isMultiple(of: 3) } ~= Int.random(in: 1..<100) func ~=<T>(evaluate: (T) -> Bool, rhs: T) -> Bool { evaluate(rhs) } ίϯύΠϥ෦ͰಡΈସ͑
ྫԠ༻ extension Set { static func ~=(lhs: Set<Element>, rhs: Element)
-> Bool { lhs.contains(rhs) } }
ྫԠ༻ extension Set { static func ~=(lhs: Set<Element>, rhs: Element)
-> Bool { lhs.contains(rhs) } } let vegitablesIDs: Set<Int> = [1, 2, 3] let fruitsIDs: Set<Int> = [4, 5, 6] func printPlantCategory(plantID: Int) { switch plantID { case vegitablesIDs: print("vegitables") case fruitsIDs: print("fruits") default: print("not vegitables nor fruits") } }
ྫ {String.init}()(“a",5)
ྫ {String.init}()(“a",5) String(”aaaaa”)
ྫจ๏ {String.init}()(“a",5) ؔͷࢀর
ྫจ๏ {String.init}()(“a",5) $MPTVSF 'VODUJPO$BMM ؔͷࢀর
ྫจ๏ {String.init}()(“a",5) ଈ࣮࣌ߦ$MPTVSF ؔͷࢀর
ྫจ๏ {String.init}()(“a",5) 'VODUJPO$BMM ؔͷࢀর ଈ࣮࣌ߦ$MPTVSF
ྫจ๏ {String.init}()(“a",5) ଈ࣮࣌ߦ$MPTVSF
ྫจ๏ String.init(“a",5)
ྫจ๏ String.init(“a",5) 🔴 Missing argument labels 'repeating:count:' in call init(repeating
repeatedValue: String, count: Int)
ྫҾϥϕϧͷআ String.init( repeating: "a", count: 5 )
ྫҾϥϕϧͷআ {String.init}()(“a”,5)
ྫԠ༻
ྫԠ༻
ྫԠ༻ String(repeating:a,count:5) // 28 {String.init}()(a,5) // 20
͓ΘΓ wΈΜͳحົͳ4XJGUΛݟ͚ͭΑ͏ʂ
More Decks by kntk
See All by kntk
App Intentsのビルドプロセスを支える技術
kntkymt
0
1.2k
WWDC26参加レポート ~In Person Labはいいぞ~
kntkymt
1
160
Swiftのレキシカルスコープ管理
kntkymt
0
360
SwiftのSIMDとその利用方法
kntkymt
2
360
Swiftのオーバーロード選択のスコア規則21種類
kntkymt
0
250
Meet high-performance image filtering in Swift
kntkymt
0
210
プログラミングを始めてからiOSエンジニアになるまで
kntkymt
0
1.8k
SwiftUIでの非同期処理データの状態管理を考える
kntkymt
1
2.7k
大学で出席管理アプリ・掲示板閲覧アプリを開発・運用している学生の話
kntkymt
1
2.9k
Featured
See All Featured
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.3k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
Java REST API Framework Comparison - PWX 2021
mraible
34
9.8k
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
650
A better future with KSS
kneath
240
18k
How GitHub (no longer) Works
holman
316
150k
BBQ
matthewcrist
90
10k
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
390
The Invisible Side of Design
smashingmag
301
52k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
570
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
410
Stop Working from a Prison Cell
hatefulcrawdad
274
21k