your example structure still doesn't behave like switch/case in CYes, it does implement fall-through. Try it. The example program I gave demonstrated it. See the two lines of output for needs_slight_cleaning? It doesn't have to match 'good value' (how could it?) to get that second output line.
If I didn't want to implement fall-through, I would have just had a bunch of ifs. If it doesn't encounter last, it's going to keep calling $case->(), which will short-circuit true if it has previously matched (that is the purpose of the $matched variable in the closure). last acts like break.Checking testing...Default Checking needs_slight_cleaning...Clean up values Whatever you need Checking good value...Whatever you need Checking totally unrelated...Something else
Update: To stack up things like you did here, just have a series of calls to $case-() as separate statements (or you could join them up with ors), and follow the last one with && whatever.
In reply to Re^5: Control Structures
by Roy Johnson
in thread Control Structures
by artist
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |