KScript 文档
ZH

变更内容

类型、模型与错误

如果你的脚本将 ->type() 与 'list' 进行比较,请将该判断改为 ->is_a(list)。类型名称现在包含元素类型,例如 'number[]' 或 'any[]'。

之前 现在
$Repo, as: $Repo, $User->create(...) Repo、as: Repo、User->create(...):类型直接以名称书写 修复 (KS6014)
Repo->from($data), $Repo->new(name: 'x'), $OutOfStock->new(item: 'tea') Repo($data)、Repo(name: 'x')、OutOfStock(item: 'tea'):调用该名称即可生成值
类型或模型中的 age: int? age?: int(T? 仍用于可能为 null 的参数) 修复 (KS6014)
model User { unique: [email] … } model User(unique: [email]) { … }:选项写在方括号内 修复 (KS6014)
model Post(timestamps, soft_deletes) { … } model Post extends [Timestamps, SoftDeletes] { … }:来自 KScript.Data 的内置混入 修复 (KS6014)
catch QueryError, catch ConnectionError catch Query、catch Connection:没有任何类型名称以 Error 结尾

除以零会抛出 Math,列表位置越界会抛出 Index。两者现在都是内置类型,因此 catch Math 与 catch Index 可以使用,且编辑器能够识别。

Edit this page on GitHub