Created with <3 with dartpad.dev.
Created
March 21, 2023 14:35
-
-
Save jakemac53/0e38e30159163ec7f9b53daadd6270a3 to your computer and use it in GitHub Desktop.
cylindrical-lantern-6201
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() { | |
print(add << null << 1); | |
print(add << 1 << null); | |
print(add << 1 << 2); | |
} | |
int add(int a, int b) => a + b; | |
extension IfNotNull<R, T extends Object> on R Function(T)? { | |
R? operator <<(T? input) { | |
var self = this; | |
if (self == null || input == null) return null; | |
return self(input); | |
} | |
} | |
extension IfNotNull2<R, S extends Object, T extends Object> on R Function(S, T)? { | |
R? Function(T)? operator <<(S? input) { | |
var self = this; | |
if (self == null || input == null) return null; | |
return (T next) => self(input, next); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment