简体   繁体   English

松脚本函数返回

[英]Pine script function return

I'm confused by pine scripts returns from functions, why does this code show a 3 and not a 1 ?我对函数返回的 pine 脚本感到困惑,为什么这段代码显示3而不是1 Shouldn't execution stop as soon as possible?执行不应该尽快停止吗?

//@version=5
indicator("Test functions", overlay = true)

returnFunction() =>
    1
    2
    3
label.new(bar_index, high, str.tostring(returnFunction()))

The value that's returned by a multi-line function is the function's last line (Pine Script Language Tutorial, nd).多行函数返回的值是函数的最后一行(Pine 脚本语言教程,nd)。 That line can either be an expression (like x + 10), a variable (x), or a variable declaration (x = 10).该行可以是表达式(如 x + 10)、变量 (x) 或变量声明 (x = 10)。

reference 参考

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM