in reply to Re: Re: mod function
in thread mod function

I'm curious (genuinely curious, not picking a fight) as to why if (...) is more explicit than unless (...)? Is it because if is more ubiquitous?

Replies are listed 'Best First'.
Re^4: mod function
by adrianh (Chancellor) on Nov 12, 2002 at 19:33 UTC

    To me the advantage of:

    if ($y % 3 == 0) { }

    is that you are explicitly stating that you are testing for a modulus being zero.

    With:

    unless ($y % 3) { }

    you are saying you are interested in Perl's idea of the statement's truth/falsehood - which is a subtly different concept.