J
John Rivers
it seems a shame you can not do this:
if (blah) {
if (blob) break;
}//if
i know it seems like you can do
if (blah && !blob) {
}//if
but what if you want to do this:
if (blah) {
bunch of code
if (blob1) break;
bunch of code
if (blob2) break;
bunch of code
if (blob3) break;
bunch of code
if (blob4) break;
bunch of code
}//if
without break you have to
if (blah) {
bunch of code
if (!blob1) {
bunch of code
if (!blob2) {
bunch of code
if (!blob3) {
bunch of code
if (!blob4) {
bunch of code
}//if
}//if
}//if
}//if
}//if
or you can put the code into a method and use return
if (blah) syntaxworkaround();
void syntaxworkaround() {
bunch of code
if (blob1) return;
bunch of code
if (blob2) return;
bunch of code
if (blob3) return;
bunch of code
if (blob4) return;
}//method
but what if there are 20 local variables that you are using?
now you have to pass them all
or create a new argument class for them
or move them up to class scope
but that might not be sensible
why not just implement break for all blocks ?
using (something) {
if (problem) break;
}//using
and on that subject
why not have multiple breaks?
while (true) {
while (true) {
if (fedup) break(2);
}//while
}//while
breaks out of two enclosing blocks
if there is amiguity between break out of loop or break out of block
maybe use a different keyword "leave" or something
so it is always clear which class of block you wish to exit
why? that's what I want to know ...
if (blah) {
if (blob) break;
}//if
i know it seems like you can do
if (blah && !blob) {
}//if
but what if you want to do this:
if (blah) {
bunch of code
if (blob1) break;
bunch of code
if (blob2) break;
bunch of code
if (blob3) break;
bunch of code
if (blob4) break;
bunch of code
}//if
without break you have to
if (blah) {
bunch of code
if (!blob1) {
bunch of code
if (!blob2) {
bunch of code
if (!blob3) {
bunch of code
if (!blob4) {
bunch of code
}//if
}//if
}//if
}//if
}//if
or you can put the code into a method and use return
if (blah) syntaxworkaround();
void syntaxworkaround() {
bunch of code
if (blob1) return;
bunch of code
if (blob2) return;
bunch of code
if (blob3) return;
bunch of code
if (blob4) return;
}//method
but what if there are 20 local variables that you are using?
now you have to pass them all
or create a new argument class for them
or move them up to class scope
but that might not be sensible
why not just implement break for all blocks ?
using (something) {
if (problem) break;
}//using
and on that subject
why not have multiple breaks?
while (true) {
while (true) {
if (fedup) break(2);
}//while
}//while
breaks out of two enclosing blocks
if there is amiguity between break out of loop or break out of block
maybe use a different keyword "leave" or something
so it is always clear which class of block you wish to exit
why? that's what I want to know ...