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

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.

主站蜘蛛池模板: 雷州市| 四平市| 陇川县| 保山市| 克山县| 察隅县| 东光县| 白城市| 临海市| 仲巴县| 手游| 金溪县| 罗源县| 衡阳市| 乌鲁木齐市| 泸水县| 鲁甸县| 丰顺县| 资溪县| 滨海县| 故城县| 景泰县| 临夏县| 仁化县| 德阳市| 新营市| 昌吉市| 修水县| 本溪市| 拉萨市| 柘城县| 七台河市| 科技| 平原县| 独山县| 资溪县| 康定县| 精河县| 昌邑市| 石阡县| 武山县|