in reply to Re^6: Given When Syntax
in thread Given When Syntax
Arbitrary keys in dispatch tables need hashes.
Furthermore all my solutions are able to define a "default" case, like given/when does.
Then goto's allow jumping to multiple lables leading to the same code, for this you need multiple entries in a dispatch hash.
And it should be clear (but mostly ignored/assumed in this thread) that given/when's linear testing of conditions is more flexible then switching to code by literal keys . (C-style I suppose)
The latter is an important but limited sub-case, which is ideally optimized under the hood, but measuring both side by side is like comparing apples and oranges.
> I did not change them because I wanted to use the various solutions as posted,
yes but you made (rather bold) statements about the execution time of "sub-calls" by benchmarking these arbitrary snippets.
edit
Better you concentrate on this point and try variations on the number of cases.
I hope its evident that "clean" benchmarks are not trival.
Cheers Rolf
( addicted to the Perl Programming Language)