2 ms·
I just had another thought. What if you could have a bank of assertions? Like this pseudocode: ``` assertion acceptableBlastNumber (int x) { x < 25; x > 5; }
by gjsman-1000 3y ago
I just had another thought. What if you could have a bank of assertions? Like this pseudocode:
```
assertion acceptableBlastNumber (int x) {
x < 25;
x > 5;
}
assertion acceptableBlastRadius (int x) {
x > 500;
x < 1000;
! (x > 750 && x < 800)
}
assertion acceptableBlastAddedNumber (int x) {
x < 1025;
x > 505;
}
public acceptableBlastAddedNumber int addBlastNumbers (acceptableBlastNumber int x, acceptableBlastRadius int y) {
return x + y;
}
addBlastNumbers (10, 720) => 730
addBlastNumbers (26, 750) => Exception
```
Though I suppose that this is getting really close to just... classes. It would just be a little more... inline? Less complicated because it would never hold state? Though I suppose, this would also mean your class can just focus on being an objec, and not on having all the definitions for the things inside it, because you can have an <assertion> <object> rather than just <object>.