Is it possible to iterate over an associative array with wildcard "*" using foreach loop?
1 Answer
No. IEEE 1800-2012 § 7.8.1 Wildcard index type states:
Associative arrays that specify a wildcard index type shall not be used in a foreach loop (see 12.7.3) or with an array manipulation method (see 7.12) that returns an index value or array of values.
1 Comment
dave_59
The reason for this restriction is that the
foreach construct needs to declare a local iterator variable, and that variable needs a type. The wildcard index is left over from the Vera language, which did not have the ability to declare an index type. Do not use wildcard indexes.