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
Search
kntk
September 21, 2025
350
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
"奇妙"なSwift
iOSDC2025 day2 LT
kntk
September 21, 2025
More Decks by kntk
See All by kntk
WWDC26参加レポート ~In Person Labはいいぞ~
kntkymt
1
79
Swiftのレキシカルスコープ管理
kntkymt
0
220
SwiftのSIMDとその利用方法
kntkymt
2
330
Swiftのオーバーロード選択のスコア規則21種類
kntkymt
0
220
Meet high-performance image filtering in Swift
kntkymt
0
180
プログラミングを始めてからiOSエンジニアになるまで
kntkymt
0
1.8k
SwiftUIでの非同期処理データの状態管理を考える
kntkymt
1
2.5k
大学で出席管理アプリ・掲示板閲覧アプリを開発・運用している学生の話
kntkymt
1
2.6k
Swiftを知って欲しい
kntkymt
1
160
Featured
See All Featured
GitHub's CSS Performance
jonrohan
1033
470k
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
170
Making the Leap to Tech Lead
cromwellryan
135
9.9k
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
390
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.3k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
Unsuck your backbone
ammeep
672
58k
Building Adaptive Systems
keathley
44
3.1k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.1k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
630
Transcript
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Λݟ͚ͭΑ͏ʂ