Created with <3 with dartpad.dev.
Created
May 6, 2023 05:37
-
-
Save dnys1/d0e678a63bbd01f1e9c07679ad1de410 to your computer and use it in GitHub Desktop.
lively-gorge-9708
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Serializable { | |
String toJson() => 'json'; | |
} | |
void main() { | |
switch (Serializable() as dynamic) { | |
case dynamic(:final Object? Function() toJson): | |
print(toJson()); | |
case _: | |
throw ArgumentError('Not serializable'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment