应该!(Should a ! function return anything?)

编程入门 行业动态 更新时间:2024-10-22 17:25:18
应该!(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)*x

or

double!(double!(a))

in a single line if you needed to.

For that reason (i.e. convenience), it has become convention.

更多推荐

本文发布于:2023-08-07 21:14:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1465982.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:function   return

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!