- 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.
推薦閱讀
- Python科學計算(第2版)
- Python數據分析基礎
- 編寫整潔的Python代碼(第2版)
- 網頁設計與制作教程(HTML+CSS+JavaScript)(第2版)
- Git高手之路
- 數據結構習題精解(C語言實現+微課視頻)
- 新編Premiere Pro CC從入門到精通
- 區塊鏈:以太坊DApp開發實戰
- Monitoring Elasticsearch
- 51單片機C語言開發教程
- Cocos2d-x Game Development Blueprints
- Building Serverless Web Applications
- C++ Fundamentals
- Orchestrating Docker
- Web前端開發精品課:HTML5 Canvas開發詳解