我的build.gradle文件中有以下任务:
task myTask(type:Exec) {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'cmd', '/c', 'whoami'
standardOutput = stdout;
}
println "Output: $stdout"
}
Run Code Online (Sandbox Code Playgroud)
当我用 运行我的任务时./gradlew myTask
,我得到以下输出:
> Configure project :
Output: retrovius
> Task :myTask FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':myTask'.
> execCommand == null!
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log …
Run Code Online (Sandbox Code Playgroud) 只是好奇哪个在 swift 中更有效/更好:
这也许可以通过一个例子更好地解释:
var one = Object()
var two = Object()
var three = Object()
func firstFunction() {
let tempVar1 = //calculation1
one = tempVar1
let tempVar2 = //calculation2
two = tempVar2
let tempVar3 = //calculation3
three = tempVar3
}
func seconFunction() {
var tempVar = //calculation1
one = tempVar
tempVar = //calculation2
two = tempVar
tempVar = //calculation3
three = tempVar
}
Run Code Online (Sandbox Code Playgroud)
这两个函数哪个更有效?感谢您的时间!