Camelia
Prev: Other forms of the if statement

Ternary Operator

examples/scalars/ternary.p6
use v6;

my $age = 42;

if $age > 18 {
    say "Above 18";
} else {
    say "Below 18";
}

say $age > 18 ?? "Above 18" !! "Below 18";

 COND ?? VALUE_IF_TRUE !! VALUE_IF_FALSE

Prev: Other forms of the if statement

Table of Contents

Comments

In the comments, please wrap your code snippets within <pre> </pre> tags and use spaces for indentation.
comments powered by Disqus

Perl 6 Tricks and Treats newsletter

Register to the free newsletter now, and get updates and news.
Email:
Name: