;结束后,它对性能产生什么影响?
function fill_twos!(a)
for i = eachindex(a)
a[i] = 2
end
end;
函数来自 julia doc 它也可以在结构之后的某些地方使用
function fill_twos!(a)
for i = eachindex(a)
a[i] = 2
end
end;
function from JULIA DOC
It is also available in some places after Struct
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
;
对性能没有任何影响。 Julia手册中的示例代码仅使用它来减少代码段中的不必要输出。通常,无论您在复制中输入什么代码,它的结果都会由REPL打印出来。如果您希望您的代码得到评估,但结果未打印出来,则可以在其结尾处添加半隆。
以上行将
pi
的值分配给x
,但是第二个线路不打印该评估的结果,因为它以半决赛结束。同样,当您在repl中输入功能时:最后一行是定义函数的输出。在示例代码段中,如果为每个函数/方法定义打印出来,这将是占用额外空间的混乱。因此,他们使用分号抑制输出。
它对函数执行的性能或任何其他方面没有影响。
The
;
doesn't have any effect on performance. The example code in the Julia manual uses it only to reduce unnecessary output in the code segments.Normally, whatever code you type in the REPL, the result of it gets printed by the REPL. If you want your code to get evaluated, but its result not be printed out, you can add a semicolon at the end of it.
Both the above lines assign the value of
pi
tox
, but the second one doesn't print the result of that evaluation because it ends in a semicolon. Similarly, when you type out a function in the REPL:That last line is the output from defining your function. In the example code segments, this would just be clutter that takes up extra space, if it was printed out for every function/method definition. And so, they're suppressing that output using the semicolon.
It has no effect on performance or any other aspect of the function execution.