Implementing Interfaces with Method Maps

  Рет қаралды 764

Pairing with Duncan

Pairing with Duncan

Күн бұрын

Пікірлер: 7
@Olekj
@Olekj 6 ай бұрын
Wouldn't there be a bug where if `invoke()` actually returned null, we'd incorrectly throw "No implementation for method $method"?
@PairingWithDuncan
@PairingWithDuncan 6 ай бұрын
Ooh good catch! Reflection is full of these little gotchas. Somewhere in the back of my mind when I was writing the code I was wondering about the implications of Map and how you tell the difference between not there and there but null. I should have listened to that voice.
@PairingWithDuncan
@PairingWithDuncan 6 ай бұрын
I think this fixes it val invocationHandler = this.getOrElse(method) { error("No implementation for method $method") } ?: error("Bad default logic for method $method") invocationHandler.invoke(args ?: emptyArray())
@Olekj
@Olekj 6 ай бұрын
@@PairingWithDuncan sweet! Really enjoying your videos ❤️
@PairingWithDuncan
@PairingWithDuncan 6 ай бұрын
Thank you, it’s nice to have somewhere to play and share the joy of it.
@erfansn869
@erfansn869 6 ай бұрын
Thanks for this
@PairingWithDuncan
@PairingWithDuncan 6 ай бұрын
I hope you find it useful
Science with Servers - Benchmarking http4k and ktor
21:15
Pairing with Duncan
Рет қаралды 467
Understanding Gradle
19:48
Pairing with Duncan
Рет қаралды 1,7 М.
So Cute 🥰 who is better?
00:15
dednahype
Рет қаралды 19 МЛН
BAYGUYSTAN | 1 СЕРИЯ | bayGUYS
36:55
bayGUYS
Рет қаралды 1,9 МЛН
The evil clown plays a prank on the angel
00:39
超人夫妇
Рет қаралды 53 МЛН
Protocols vs ABCs in Python - When to Use Which One?
15:31
ArjanCodes
Рет қаралды 45 М.
Master Golang with Interfaces
21:54
Kantan Coding
Рет қаралды 20 М.
Andrew Kelley   Practical Data Oriented Design (DoD)
46:40
ChimiChanga
Рет қаралды 162 М.
What Makes A Great Developer
27:12
ThePrimeTime
Рет қаралды 234 М.
Migrating Kotlin Context Receivers
28:53
Pairing with Duncan
Рет қаралды 1 М.
7 Benefits of First-Class Functions - JavaScript Tutorial
25:04
Golang: The Last Interface Explanation You'll Ever Need
17:58
Flo Woelki
Рет қаралды 29 М.
The Biggest React Framework You've Never Heard of
20:29
Theo - t3․gg
Рет қаралды 14 М.
Upgrading Dependencies for No Fun and No Profit
23:38
Pairing with Duncan
Рет қаралды 561
A Practical Example How To Use Interfaces In Golang
14:42
Anthony GG
Рет қаралды 31 М.
So Cute 🥰 who is better?
00:15
dednahype
Рет қаралды 19 МЛН