简体   繁体   English

为什么Scala中的格子?

[英]Why's type lattice in Scala?

I heard someone said: 我听到有人说:

"Scala uses a type lattice rather than a type hierarchy, which is different from Java". “Scala使用类型的格子而不是类型层次结构,这与Java不同”。

I do not quite understand what the meaning type lattice is and what the main difference between type lattice and type hierarchy is. 我不太清楚格子的意义是什么,以及类型网格类型层次结构之间的主要区别是什么。

Could someone explain this term to me? 有人可以向我解释这个词吗?

Its essentially means that : The type hierarchy for Scala is a lattice, ie it has a “bottom” as well as a “top”. 它本质上意味着: Scala的类型层次结构是一个点阵,即它有一个“底部”和一个“顶部”。

在此输入图像描述

As seen from the image the top type here is Any and the bottom is Nothing . 从图像中可以看出,这里的顶部类型是Any ,底部是Nothing

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM