Scala-12.对象(object)

2019-07-13  本文已影响0人  悠扬前奏
class Person {
    var name: String = _
}

object Person {
    def apply(name: String): Person = {
        val p = new Person
        p.name = name
        p
    }
}
case class Person(var name:String)
上一篇下一篇

猜你喜欢

热点阅读