Boolean values: Difference between revisions

Content added Content deleted
(→‎{{header|Perl}}: Expanded.)
(Added Perl 6.)
Line 188: Line 188:


Perl has no builtin "true" or "false" keywords. However, as a special case, literal <tt>1</tt>s and <tt>0</tt>s will never cause a "Useless use of a constant in void context" warning. Another special case worth pointing out here is that the string <tt>'0 but true'</tt> won't provoke a warning if it's used as a number.
Perl has no builtin "true" or "false" keywords. However, as a special case, literal <tt>1</tt>s and <tt>0</tt>s will never cause a "Useless use of a constant in void context" warning. Another special case worth pointing out here is that the string <tt>'0 but true'</tt> won't provoke a warning if it's used as a number.

=={{header|Perl 6}}==
<!-- No "works with" because Bool isn't a proper role in Rakudo yet (as of release #22). -->
Perl 6 provides an enumeration <code>Bool</code> with two values, <code>True</code> and <code>False</code>. Values of enumerations can be used as ordinary values or as mixins:

<lang perl6>my Bool $crashed = False;
my $val = 0 but True;</lang>

For a discussion of Boolean context (i.e. how Perl decides whether something is true or false), see [http://perlcabal.org/syn/S02.html#Context Synopsis 2].


=={{header|PHP}}==
=={{header|PHP}}==