| Class | Node::WHEN |
| In: |
ext/nodeinfo.c
|
| Parent: | Node |
Represents either a conditional in a case/end block:
case value
when head
body
next
end
or the first element of a a case/end block with no conditional:
case
when head
body
next
end
In the first case, value is evaluated and head is evaluated, and they are compared using head === value. If the result is true, then body is evaluated and no more when conditions are tried, otherwise the interpreter evaluates the next node.
In the second case, head is tested using rtest(value). If the result is true, then body is evaluated and no more when conditions are tried, otherwise the interpreter evaluates the next node.
If the condition evaluates to false and there are no more when conditions to try, the result of the expression is nil.
If the next expression to try is not a WHEN node, then it represents an else element and is evaluated unconditionally.