Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在电梯应用中:
package bootstrap.liftweb class Boot { def boot = {} }
我想知道为什么Bootaclass不是 a object?它应该只执行一次,所以我认为object Boot更合理。
Boot
class
object
object Boot
object Boot并且class Boot没有限制你def boot可以执行多少次。
class Boot
def boot
唯一可能受到影响的是实例。class Boot可以有多个实例,而object Boot将是一种static方法。只有调用的对象才Boot需要是static.
static