the basic syntax of switch statement in ruby is
case expression
when condition1
statements1
when condition2
statements2
else
statements
end
Is there a way to get control expression value in statements?
Means, is there some variable which stores expression value which can be used directly – and expression need not be called again in statements body?
There is no magic variable. It’s no trouble to use an ordinary variable: