问题
Is it possible to write classes using functions in Scala, like one would do in Javascript ?
回答1:
Can you use any function as a constructor? No. Can you use closures as "poor man's objects"? Yes. But what you get in this way is not called a class in Scala.
来源:https://stackoverflow.com/questions/38433112/is-it-possible-to-write-classes-using-functions-in-scala