- Julia 1.0 Programming Complete Reference Guide
- Ivo Balbaert Adrian Salceanu
- 295字
- 2021-06-24 14:21:49
Concrete and abstract types
In this hierarchy, some types, such as Number, Integer, and Signed, are abstract, which means that they have no concrete objects or values of their own. Instead, objects or values are of concrete types given by the result of applying typeof(value), such as Int8, Float64, and String. For example, the concrete type of the value 5 is Int64 given by typeof(5) (on a 64-bit machine). However, a value also has the type of all of its supertypes; for example, isa(5, Number) returns true (we introduced the isa function in the Types section of Chapter 2, Variables, Types, and Operations).
Concrete types have no subtypes and might only have abstract types as their supertypes. Schematically, we can differentiate them as follows:

An abstract type (such as Number and Real) is only a name that groups multiple subtypes together, but it can be used as a type annotation or used as a type in array literals. These types are the nodes in the type hierarchy that mainly serve to support the type tree. Also, note that an abstract type cannot have any fields.
The abstract type Any is the supertype of all types, and all the objects are also instances of Any.
At the other end is Union{}: this type has no values and no subtypes. All types are supertypes of Union{} , and no object is an instance of Union{}. It is unlikely that you will ever have to use this type. The Nothing type has one value called nothing.
When a function is only used for its side-effects, convention dictates that it returns nothing. We have seen this with the println function, where the printing is the side-effect, for instance:
x = println("hello") #> hello x == nothing #> true
- 大學計算機基礎實驗教程
- Apache Spark 2.x Machine Learning Cookbook
- Oracle Database 12c Security Cookbook
- 前端HTML+CSS修煉之道(視頻同步+直播)
- 從零開始學C語言
- 深入實踐Kotlin元編程
- 小程序從0到1:微信全棧工程師一本通
- Learning Unreal Engine Game Development
- SAP Web Dynpro for ABAP開發技術詳解:基礎應用
- 循序漸進Vue.js 3前端開發實戰
- C# 10核心技術指南
- Swift Essentials(Second Edition)
- 深度學習:基于Python語言和TensorFlow平臺(視頻講解版)
- Learning Ext JS(Fourth Edition)
- 給產品經理講技術