When-Is statements are similar to the switch/case statements found in other
languages like Java or Visual Basic. The
do
keyword
is entirely optional as well.
YASS
when($a) is 0 do //Do something when $a = 0 is 1 do //Do something when $a = 1 is 2 do //Do something when $a = 2 otherwise do //Do something when $a is something else end when
The When-Is statement can also be written with braces like PHP or C:
YASS
switch($a) { case 0 //Do something when $a = 0 case 1 //Do something when $a = 1 case 2 //Do something when $a = 2 default //Do something when $a is something else }
Efficiency of the When-Is statement
ZPE 1.7.12 (December 2019) changed the way that the When-Is statement works so that instead of generating an FAST for the cases, it generates a hash-map using a strong-key hashing mechanism. Unfortunately, this means that with smaller statements the efficiency is actually worse. However, with larger statements it is considerably better due to instant access.
There are no comments on this page.