朱莉娅没有价值 [英] None value in Julia

查看:85
本文介绍了朱莉娅没有价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Python中None值的Julia等效项是什么? (如此处内置常量中所示.)

What is the Julia equivalent of the None value in Python? (As shown here in built-in constants.)

推荐答案

None的Julia等效项是常量nothing:由没有任何有趣意义的表达式和函数返回的值.在两种语言中,当表达式对其求值时,该值都不会在交互式提示中显示,否则只是正常值.除了印刷行为和人们一致同意的是,当没有任何有趣的东西可以返回时,这是一个返回的值,这一点没有什么神奇的了. C函数的返回类型之后,nothing的类型称为Void,没有返回有趣的内容.

The Julia equivalent of None is the constant nothing: a value that is returned by expressions and functions which don't have anything interesting to return. In both languages, this value is not printed at an interactive prompt when an expression evaluates to it, but is otherwise just a normal value. There's nothing magical about it other than the printing behavior and the fact that people agree by convention that it is the value one returns when there is nothing interesting to return. The type of nothing is called Void after the return type of C functions with nothing interesting to return.

Julia的类型系统还可以表达这样的概念,即表达式不能产生任何值,例如如果它引发错误或属于无法执行的基本块的一部分(死代码).永远不会产生值的表达式的类型为空联合类型Union{}:零类型的联合,其中没有值是实例.这与nothing的类型不同–因为nothing是正常值(但无趣),所以它不能是Union{}的实例.

Julia's type system can also express the concept that an expression cannot produce any value – e.g. if it throws an error or is part of a basic block that cannot execute (dead code). The type of an expression that can never produce a value is the empty union type, Union{}: a union of zero types, of which no values are instances. This is distinct from the type of nothing – since nothing is a normal (but uninteresting) value, so it cannot be an instance of Union{}.

另请参见:

这篇关于朱莉娅没有价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆