foreach ... else statement
Brian
digitalmars at brianguertin.com
Tue Jan 6 02:37:42 PST 2009
On Mon, 05 Jan 2009 11:13:49 +0100, grauzone wrote:
> void somefunction() {
> do_stuff();
> if (error)
> goto error_exit:
> do_more_stuff();
>
> return;
>
> error_exit:
> handle_error();
> }
>
> This could be replaced by something like this:
>
> void somefunction() {
> error_exit: {
> do_stuff();
> if (error)
> break error_exit;
> do_more_stuff();
>
> return;
> }
> handle_error();
> }
>
> D's scope can do the same thing.
neither of those seem necessary in that example, whats wrong with this:
void somefunction() {
do_stuff();
if (error)
handle_error();
else
do_more_stuff();
}
More information about the Digitalmars-d
mailing list