Block syntax for more than one block
Brought to you by:
bonniot
"If an anonymous method would normally be used, it is
permissible to omit the arguments and => and instead
write the code for the anonymous method in a block
following the call. "
Would it be possible to extend this to more than one block?
void ifTrueifFalse(boolean test, void->void ifTrue,
void->void ifFalse)
{ if (test){ ifTrue(); } else { ifFalse(); } }
void main(String[] args) {
ifTrueifFalse(1 < 0)
{ println("Test was True!"); println("Great!"); }
{ println("Test was False!"); println("Ouch!"); }
}