in reply to IF condition with a range

Assuming integers,

if ($y-1 <= $x && $x <= $y+1)
or
if (abs($y-$x) <= 1)

Replies are listed 'Best First'.
Re^2: IF condition with a range
by Anonymous Monk on Jul 16, 2018 at 14:16 UTC
    True! Thank you!

      You could also use

      if (abs($y-$x) <= 1)

      (Added to earlier post)