- 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.
- 演進(jìn)式架構(gòu)(原書第2版)
- The Supervised Learning Workshop
- Raspberry Pi for Python Programmers Cookbook(Second Edition)
- Mobile Application Development:JavaScript Frameworks
- Mastering Ember.js
- ASP.NET Core 2 and Vue.js
- FreeSWITCH 1.6 Cookbook
- Getting Started with Python Data Analysis
- Hands-On Swift 5 Microservices Development
- TradeStation交易應(yīng)用實(shí)踐:量化方法構(gòu)建贏家策略(原書第2版)
- .NET 3.5編程
- Flutter跨平臺(tái)開(kāi)發(fā)入門與實(shí)戰(zhàn)
- Mastering Backbone.js
- Mastering Android Studio 3
- Building Apple Watch Projects