News for hackers. Stuff that matters.
Re:Java Secret: Using an enum to build a State machine by noblethrasher on Tuesday July 12, 2011 @01:44PM (#2755642)
Since a function is just an object with a single 'apply' method, I agree with the spirit of your code.

However, the concept is more naturally/idiomatically expressed in C# using an abstract class and variants (i.e. derived classes) for the various states.

This also gives you the advantage that you can encode valid state transitions in the type system itself.

There are no comments on this comment yet.