Jun 28, 2016
A generic fail method
I’m a fan of expressing this
like this
But sometimes the last part actually looks like
in which case you can’t directly translate the whole thing to a conditional expression, since this doesn’t compile:
Here’s where this little utility method comes in handy:
which allows you to write
The generic return type ensures that the method always fits in as an expression. Unfortunately JUnits Assert.fail
doesn’t follow this pattern!