andThen andThen andThen... Scala, where's my car?
When I saw Dude Where's My Car?, several years ago with my wife (who is Chinese), she started laughing right as they pulled into the parking lot of a Chinese restaurant . I had no idea why, but she said to wait until the end of the scene. In the scene, after they order each item, a voice from the speaker says, "and then?" and continues after they run out of things to order until Ashton Kutcher eventually destroys the speaker in frustration. When the scene was over, I asked her why she started to laugh at the beginning of the scene. She said she had heard people quoting that at work, but she never realized that the Chinese name of the restaurant, which she saw at the beginning of the scene, was "And Then." Appropriately, Scala defines infinite loops in actors using andThen. Here's how... In Scala, one way to compose functions is "f andThen g", which is the same as def newFunc[T](x: T) = g(f(x)) You can think of it as "evaluate f(x) and the...