Last Updated: February 25, 2016
·
710
· constantology

using functions to `case` match in `switch` statements

I've never seen this used, however, I was pondering the feasibility of using a switch statement where each case match executes a function instead of simply matching on a static value.

This is best explained by viewing the gist example: https://gist.github.com/4217094

I doubt it would be more/less performant than using if/else, however, I like the cleanliness of it, especially if, like me, you don't like excessive use of braces...

2 Responses
Add your response

That's interesting, thanks for sharing!

over 1 year ago ·

np. :^)

over 1 year ago ·