Julia: 为什么要设计nothing
来源:互联网 发布:2007办公软件下载 编辑:程序博客网 时间:2024/04/29 21:09
Julia中的nothing是什么玩艺?简单地说,就是不返回值。
为什么要这个呢?
你看一下。
情况一:f()里面,事实上,有没有nothing,没有什么差别;
function f(a) for i in eachindex([1:10]) a[1] =1; end #nothing; # for 循还外,默认不返回值。 end
情况二:但在ff()里面,有没有nothing,差别就大了。
function ff(k) k[1] =1; #nothing; # 显示通知,不要有返回值了。如果不加nothing,则会有返回值。 end
不信,你可以试一下。
b =[2,2] c =f(b) c
0 0
- Julia: 为什么要设计nothing
- Nothing
- nothing
- NOTHING
- nothing
- nothing
- nothing
- nothing
- nothing
- Nothing
- nothing
- nothing
- Nothing
- nothing
- nothing
- nothing
- nothing
- nothing
- 不能声明为虚函数的函数
- Java中的static Class和non static Class
- 从源码到apk——apk打包过程
- 软件设计七大原则
- getline用法实例
- Julia: 为什么要设计nothing
- ios常用知识
- 整数划分问题
- Spring第一天学习总结
- 一总结
- 第六周上机实践项目——项目1-分数类的雏形
- Linux内核分析(六)
- 比较实验
- STM8S103 LCD5110例程带字库