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

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.

主站蜘蛛池模板: 印江| 汉沽区| 交城县| 固原市| 化隆| 常熟市| 商水县| 江永县| 双柏县| 凤庆县| 荔波县| 璧山县| 彩票| 常宁市| 阜新| 玛多县| 石渠县| 漠河县| 林芝县| 奎屯市| 巴彦县| 云安县| 鸡泽县| 龙岩市| 贵定县| 昌江| 贺兰县| 土默特右旗| 定安县| 翁源县| 乐亭县| 额敏县| 隆尧县| 平陆县| 辛集市| 赤壁市| 彩票| 高阳县| 罗城| 西和县| 皮山县|