The question here is "what's your favorite non-C-like flow control statement/construct that you've seen in a programming language" but I'm gonna start with a little preamble.
I'm very familiar with C-style flow control:
if (condition)
{ thing; }
else
{ otherThing; }
// And, thanks to C++17:
if (auto v= initializer(); condition)
{ thing(v); }
else
{ otherThing(v); }made with @nex3's syntax highlighter
for (int i = 0; i < 5; i++)
{ thing(); }made with @nex3's syntax highlighter
for (var e : elements)
{ thing(e); }made with @nex3's syntax highlighter
while (condition)
{ thing(); }made with @nex3's syntax highlighter
(plus, ya know, do/while and goto)
I've seen a few others, like Rust's loop (basically a while(true)):
loop
{
thing();
if (something)
{ break; }
}made with @nex3's syntax highlighter
and Swift's ranges, which are nice:
for i in 0..<4
{ thing(i); }made with @nex3's syntax highlighter
What I'm wondering is: what are your favorite bits of flow control logic (loops, jumps, conditionals, etc) that don't show up in C or C++? Are there loop forms that you think are truly elegant? Is there a switch-like construct that doesn't suck like C's switch statement does?
