On 28 September 2010 21:19, Julian Andres Klode <[email protected]> wrote: > On Mo, 2010-09-27 at 02:55 +0200, Frederik Sdun wrote: >> This is just for convinience, for the not unusual case of: >> if (args.length > 0) >> foreach(...) >> else >> ...
Personally I find myself, in almost every language, wrapping for(each) statements in "if (the list has items) ... else ...", which is exactly what this feature addresses. And, it's essentially saying exactly what such a structure looks like; do this loop, else do this other thing if the loop never happened (because there weren't any items). Absolutely fantastic that a useful language has this! > That would be confusing for people with Python background, as 'else' is > executed when the loop is exhausted; that is if there was no > return/break in the loop body. That doesn't strike me as particularly useful, or as a particularly good definition of "else" for that matter. I'd consider that more of a "then" situation, with "else" used because it's already a handy reserved keyword that they couldn't think of a better use for. Lets not punish Vala for Python's lack of good taste, though "then" as in "Python's for...else" could be handy too. ;) _______________________________________________ vala-list mailing list [email protected] http://mail.gnome.org/mailman/listinfo/vala-list
