- Learn Scala Programming
- Slava Schmidt
- 141字
- 2021-06-10 19:35:44
Type constraints
Type constraints are rules associated with a type. They define a subset of all types that, for example, a variable can have. A type constraint takes the form of lower bound (subtype relation) or upper bound (supertype relation). It is possible to define multiple constraints for a single type. In this case, a type must satisfy both of them. Constraints are defined using the symbols >: (lower, unhappy bound) and <: (upper, happy bound), and the direction of the sign corresponds to the reversed direction of the arrow on the UML diagram, as shown in the following screenshot:
The type constraints are inclusive, which is why type B represents both the upper and lower bounds. Besides B in our type hierarchy, only A obeys the LOWER type constraint and only C obeys the UPPER constraint.
- 深度實(shí)踐OpenStack:基于Python的OpenStack組件開(kāi)發(fā)
- ASP.NET Web API:Build RESTful web applications and services on the .NET framework
- Mastering Entity Framework Core 2.0
- Intel Galileo Essentials
- R語(yǔ)言數(shù)據(jù)可視化之美:專業(yè)圖表繪制指南
- Designing Hyper-V Solutions
- Learning Data Mining with R
- 青少年學(xué)Python(第1冊(cè))
- NetBeans IDE 8 Cookbook
- Mastering React
- Python函數(shù)式編程(第2版)
- Application Development with Parse using iOS SDK
- Mastering ASP.NET Core 2.0
- SQL Server 2008實(shí)用教程(第3版)
- Android項(xiàng)目實(shí)戰(zhàn):博學(xué)谷