In dart I want to set a plus or minus operator as a variable.
var plusOrMinus;
if (x >= y) {
plusOrMinus = -;
} else {
plusOrMinus = +;
}
How do I define plusOrMinus
so that it can be used like this:
double width = 10.0 plusOrMinus 5.0;
Capture the operation as a closure:
final operation = x >= y ?
(a, b) => a - b :
(a, b) => a + b;
final width = operation(10.0, 5.0);