Is it possible to write classes using functions in

2019-10-02 01:34发布

问题:

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.