Last active
February 2, 2022 15:40
-
-
Save ltOgt/04212037dca1d7a68b4e89dddc750bbd to your computer and use it in GitHub Desktop.
This file contains 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
void main() { | |
dynamic t = TC(); | |
print(ifHasMethodElse(() => t.code, "")); | |
} | |
ifHasMethodElse(Function closureWithCall, dynamic elseThis) { | |
try { | |
return closureWithCall(); | |
} catch (NoSuchMethodError, e) { | |
return elseThis; | |
} | |
} | |
class TC {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment