gpt4 book ai didi

class - 类片段和对象片段之间的区别

转载 作者:行者123 更新时间:2023-12-04 18:48:37 25 4
gpt4 key购买 nike

我想知道提升中的类片段和对象片段之间的确切区别是什么。

如果我有

class Foo {
var a: String
def render(n:NodeSeq) = {
<h3> you chose {a} </h3>
}
}


object Bar {
var b: String
def render(n:NodeSeq) = {
<h3> you chose {b} </h3>
}
}

它们之间的具体区别是什么,做 ab有不同的行为。
simply lift据说

In this case, the snippet is an object singleton because it does not take any constructor parameters and has no instance variabled.



这是否意味着对于每个用户, Bar会一样吗?

我知道这是一个菜鸟问题,但是我需要对此非常清楚,并且我无法很好地匹配片段中对象和类之间的差异。

最佳答案

this page .

基本上,将为每个 http 请求创建一个新的 Foo 实例(因此将同时存在许多实例),但同时只有一个 Bar 实例存在。

关于class - 类片段和对象片段之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9774727/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com