Monday, November 30, 2015

Perl6: if, unless, with, and without

   #
   #  if, unless, with, and without
   #

   my $age = 19;
   my $age2;

   if not $age < 19 {
      say 'Adult';
   }

   unless $age < 19 {
      say 'Adult';
   }

   with $age {
      say '$age has a value';
   }

   with $age2 {
      say '$age2 has a value';
   }

   without $age2 {
      say '$age2 does not have a value';
   }


$ perl6 control.pl6
Adult
Adult
$age has a value
$age2 does not have a value

No comments:

Post a Comment