C++ Logo

std-proposals

Advanced search

Re: [std-proposals] if !(condition)

From: Thiago Macieira <thiago_at_[hidden]>
Date: Sat, 20 Apr 2024 14:34:17 -0700
On Saturday 20 April 2024 12:53:56 GMT-7 Andrew Tomazos via Std-Proposals
wrote:
> (There is existing practice in another language, can't remember which one.)

Perl.

It also has a suffix syntax so you can write:

  next unless condition;
  last if condition;

next and last are the Perl equivalents to continue and break, respectively. In
the post-statement position, the parentheses are also optional.

For the record, it also has an until keyword to go along with while, which
does the same that unless does to if: it's the opposite condition. That is, it
repeats the loop until the condition becomes true.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Principal Engineer - Intel DCAI Cloud Engineering

Received on 2024-04-20 21:34:27