官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 惠来县| 于田县| 安阳市| 万荣县| 安龙县| 尼玛县| 县级市| 乐陵市| 富裕县| 台州市| 嘉鱼县| 龙口市| 苏尼特左旗| 赣榆县| 杭州市| 贵港市| 宁晋县| 怀仁县| 邢台县| 醴陵市| 南木林县| 大竹县| 贵溪市| 肇东市| 庐江县| 彰武县| 河曲县| 玛纳斯县| 黑山县| 石首市| 长阳| 安国市| 比如县| 大埔县| 会昌县| 余姚市| 富顺县| 治县。| 古丈县| 克拉玛依市| 红原县|