Menu

#45 Block syntax for more than one block

open
nobody
None
5
2006-04-08
2006-04-08
Isaac Gouy
No

"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!"); }
}

Discussion


Log in to post a comment.