iRules expression lab

Evaluate an expression the way expr and if do in an iRule and see every step: how each operand was read, numeric or text comparison, precedence, where && stopped, and == next to eq. Tcl 8.4 or iRules mode. Local, no network.

Netværk
Try

Result 1integer

How precedence groups it

($x == $y)

Every operator with its operands in parentheses. Tcl applies the higher-precedence operator first, whatever the spacing.

Evaluation, step by step

  1. $x == $y1integer
    • Compared as integers: 10 and 10.
    1. $x012
      • Reads the variable x.
    2. $y10
      • Reads the variable y.

The same operands under each comparison operator

ExpressionResultHow it compares
$x == $y1Numbers when both sides read as numbers; otherwise text.
$x eq $y0eq compares text only.
$x < $y0Numbers when both sides read as numbers; otherwise text.
$x > $y0Numbers when both sides read as numbers; otherwise text.

Variables after the set commands

$x
012
$y
10

Referencer

Appears in these workflows