in reply to RFC: "assignary" operator ?= :
You can think of it as an "upgrading" operation for a boolean variable.
Like if a variable contains a Perl boolean, you can upgrade it to a JSON boolean:
$var ?= JSON::PP::true : JSON::PP::false;
Or you can upgrade a Perl boolean to some HTML:
my $is_ready = 1; $is_ready = 0 if $service->not_configured(); $is_ready = 0 if $service->payment->status() ne 'paid'; $is_ready ?= '<span class="green">yes</span>' : '<span class="red">no< +/span>'; print "<p>Service ready? $is_ready</p>";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: RFC: "assignary" operator ?= :
by Anonymous Monk on Dec 09, 2019 at 02:18 UTC |