函数名后面的感叹号是什么意思? [英] What does an exclamation mark mean after the name of a function?
本文介绍了函数名后面的感叹号是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我见过这样的函数
function operator!(c::Matrix, out::Matrix)
......
end
!
在这里是什么意思?
推荐答案
在 Julia 中,将 !
附加到修改其参数的函数的名称.原因是 Julia 函数参数是 passed-by-sharing,没有这个砰"的一声按照惯例,要知道一个函数是否会改变输入参数的内容并不容易.
In Julia, it's a convention to append !
to names of functions that modify their arguments. The reason is Julia function arguments are passed-by-sharing, without this "bang" convention, it's not easy to know whether a function will change the content of input arguments or not.
这篇关于函数名后面的感叹号是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文