Exercise 1: Why switch Over an Array Produces Four Results — Possible Solution ==================================================================== WHY FOUR SEPARATE RESULTS ------------------------------ Per this chapter, when switch is handed an array instead of a single value, it automatically iterates that array - running its clauses once for EACH element, not once total for the whole array. @(1, 2, 3, 4) has four elements, so switch evaluates {$_ % 2 -eq 0} against each of the four values in turn (with $_ representing the current element each time), producing one result per element: "1 is odd", "2 is even", "3 is odd", "4 is even" - four separate outputs, one per array element. WHY THIS IS DIFFERENT FROM A SINGLE-VALUE SWITCH ------------------------------ A switch given a single value (like the earlier $status example in this chapter) only ever evaluates its clauses once, against that one value. It's specifically being handed a collection that triggers switch's own automatic per-element iteration behavior - a feature most other languages' switch statements simply don't have at all. WHY THIS WORKS AS AN ANSWER ------------------------------ It correctly identifies that switch automatically iterates when given a collection, correctly explains that each of the four elements is evaluated separately against the clause conditions, and correctly connects the four-element array to the four separate results.