首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为Motoko中的字段保留转义关键字

为Motoko中的字段保留转义关键字
EN

Stack Overflow用户
提问于 2022-02-26 15:42:06
回答 1查看 29关注 0票数 0

作为保留关键字的字段名如何能够“转义”以用于类型?

代码语言:javascript
复制
type User = {
    type: Text; // `type` cant be used since its reserved
};

我希望能够返回字段名为type的数据。

是否有字符前缀或其他东西,以便在请求中序列化时,它会输出“type”?

或者为字段指定“type”的某种序列化装饰。

EN

回答 1

Stack Overflow用户

发布于 2022-02-26 15:52:24

来自文档If the field name is a reserved name in Motoko, an undescore is appended. So record { if : bool } corresponds to { if_ : Bool }.

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71278020

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档