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

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.

主站蜘蛛池模板: 青龙| 兴隆县| 灵武市| 天柱县| 泸定县| 新郑市| 宣城市| 黑山县| 喀什市| 普定县| 洪湖市| 绥芬河市| 绍兴县| 元氏县| 紫阳县| 利津县| 阿图什市| 葫芦岛市| 青川县| 怀来县| 云阳县| 肥乡县| 陆丰市| 抚远县| 巴南区| 巴林右旗| 乐至县| 九龙县| 库尔勒市| 故城县| 石景山区| 涟水县| 阿克苏市| 繁峙县| 拜泉县| 友谊县| 左权县| 突泉县| 涞水县| 德化县| 东至县|