应该!(Should a ! function return anything?)
在风格指南中,它表示修改其参数的函数应标有! 。 然而在给出函数double!的例子中 double! 返回修改的参数a 。 为什么要返回它,如果它已被修改? 有必要吗?
In the style guide it says that functions that modify their arguments should be marked with a !. However in the example given the function double! returns the modified argument a. Why return it if it has already been modified? Is it necessary?
最满意答案
它不需要任何费用,并且可以让您执行以下操作:
b = double!(a)*x要么
double!(double!(a))如果你需要的话,可以在一行中。
出于这个原因(即方便),它已经成为惯例。
It doesn't cost anything and enables you do things like:
b = double!(a)*xor
double!(double!(a))in a single line if you needed to.
For that reason (i.e. convenience), it has become convention.
更多推荐
发布评论