- Learn Kotlin Programming(Second Edition)
- Stephen Samuel Stefan Bocutiu
- 153字
- 2021-06-24 14:13:31
Limitations
The Contracts API is a very interesting and useful functionality. However, keep in mind the Contracts API syntax is experimental and could be subject to change (at the time of writing these lines, Kotlin 1.3.10 is out).
The current implementation has a few limitations:
- Contracts can only be used with top-level functions. This means they cannot be used on fields and functions defined by a class.
- The function needs to start with the contract code.
- Describing a contract is limited to the function parameters but not its nested fields. If the Command class used earlier had a user field, we couldn't have placed an effect on command.user.
With great power comes great responsibility. In this case, it means the developer is solely responsible for the contract block. The user needs to make sure the contract block sets the effect correctly. At the moment, there is no way to validate the contract block.
推薦閱讀
- 零基礎學Visual C++第3版
- GeoServer Cookbook
- Learning ArcGIS Pro 2
- Mastering QGIS
- 軟件測試項目實戰之性能測試篇
- SQL基礎教程(第2版)
- R語言與網絡輿情處理
- Spring Boot+Vue全棧開發實戰
- 從零開始:UI圖標設計與制作(第3版)
- Getting Started with Python
- 多媒體技術及應用
- 會當凌絕頂:Java開發修行實錄
- Developing Java Applications with Spring and Spring Boot
- Web前端測試與集成:Jasmine/Selenium/Protractor/Jenkins的最佳實踐
- Raspberry Pi Robotic Projects