gpt4 book ai didi

java - build().perform() 和 Perform() 之间有什么区别

转载 作者:行者123 更新时间:2023-12-01 19:44:16 30 4
gpt4 key购买 nike

一些文章建议现在 build() 包含在 perform() 本身中,而其他人则建议当要链接多个操作时使用 build().perform()一起。

最佳答案

build() 包含在 perform() 中,您可以在 source code 中看到它。

public void perform() {
build().perform();
}

方法内的perform()调用内部类BuiltAction中的perform()方法。

在代码中调用 build().perform() 实际上是调用 build() 两次, build().build().perform() .

build

Generates a composite action containing all actions so far, ready to be performed (and resets the internal builder state, so subsequent calls to build() will contain fresh sequences).

performe

A convenience method for performing the actions without calling build() first.

这几乎没有误导性(IMO),因为正在调用 build(),即使是隐式调用。

关于java - build().perform() 和 Perform() 之间有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54053633/

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