- Learn Scala Programming
- Slava Schmidt
- 199字
- 2021-06-10 19:35:47
Summary
The type system is one of the key components of the Scala language. It allows the developer to express expectations about the behavior of the program, which can then be checked at compile time. This reduces the number of tests needed to verify the correctness of the solution and the possibility of runtime errors.
Usually, strictly typed languages are associated with verbose code. Normally, this is not the case with Scala because of its powerful type inference mechanism.
Scala allows you to define very narrow types containing a single value as well as much wider types, even those represented as a combination of other types.
The type definition can be made more precise by using type constraints, type parameters, and variance.
We also looked at some examples of how the type system can be used to express domain constraints.
Needless to say, Scala's ecosystem is much richer than what we have covered here. Some open source libraries offer advanced type constraints that are expressed as refined types, fixpoint types, or tagged types. Other libraries, such as shapeless, provide the possibility for type-level programming, which allows you to express and verify quite complex program logic at compile time.
- 現(xiàn)代C++編程:從入門到實(shí)踐
- 大話PLC(輕松動(dòng)漫版)
- Spring Boot開發(fā)與測試實(shí)戰(zhàn)
- Visual C++實(shí)例精通
- Web程序設(shè)計(jì)(第二版)
- Modular Programming in Java 9
- 基于Struts、Hibernate、Spring架構(gòu)的Web應(yīng)用開發(fā)
- Getting Started with Hazelcast(Second Edition)
- 常用工具軟件立體化教程(微課版)
- Building Microservices with .NET Core
- Internet of Things with ESP8266
- Microsoft HoloLens By Example
- Access數(shù)據(jù)庫應(yīng)用教程(2010版)
- 零基礎(chǔ)學(xué)Java(第5版)
- 輕松學(xué)Scratch 3.0 少兒編程(全彩)