>>41
Thanks, using the or is a lot more succinct and easy to read than the metatable way I used, and factoring the values out is nice. I only included the values inside of the functions to show that the functions had the ability to access and mutate variables in the outer function's local scope. This is a lot more difficult to pull off in Java. You can get lexical closures for
final variables, which would let the case functions access values in the outer scope (which you would have to assign into
final variables), but they would not be able to mutate them. So you would either have to take advantage of their return values somehow, or pass in references to objects for them to operate on. It's never really a switch and case statement, but it could still be useful for some things, but it would never be a convenient syntactical structure. It could instead be something that is constructed once, and then passed around and used.