节奏的参考类型
我一直在使用Flow Playground ft教程,我提出了疑问。 引用应该具有自己的类型,是引用资源类型的引用;例如,对于@collectible
资源,其类型为< a.0 ... 01.Collectible>()
参考该资源&amp; collectible < /code>我期望像
&lt;&amp; a.0..01.collectible&gt;()
,但是当在引用上调用getType()函数时,我得到的类型与我在在引用资源上调用该功能。
要澄清,此代码...(可以在上面链接的事务“传输令牌”的第32行中找到)
log(self.temporaryvault.gettype())
log log (receiverRef.getType())
log(self.temporaryVault.getType()== receveriverRef.getType())
...我得到此输出
- 类型&lt; a.0000000000000000000202.exampleteken。 Vault&gt;()
- type&lt; a.0000000000000002.c.exampletoken.vault&gt;()
- true
我在这里缺少什么?
I have been messing around with types, specifically reference types, using the flow playground ft tutorial and I came up with a doubt.
References are supposed to have their own type, a reference to the referenced resource type; e.g for a @Collectible
resource whose type will be <A.0...01.Collectible>()
a reference to that resource &Collectible
I was expecting something like <&A.0..01.Collectible>()
but when calling the getType() function on a reference I get the same type that I get when calling said function on the referenced resource.
To clarify, this code... (that can be found on the line 32 of the transaction "Transfer tokens" on the link above)
log(self.temporaryVault.getType())
log(receiverRef.getType())
log(self.temporaryVault.getType() == receiverRef.getType())
...I get this output
- Type<A.0000000000000002.ExampleToken.Vault>()
- Type<A.0000000000000002.ExampleToken.Vault>()
- true
What I'm missing here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
引用始终会自动解除参考 - 操作是在引用值(而不是参考)上执行的。
访问是:例如:
ref.field
或ref.func()
ref [0]
Accesses on references always automatically dereference the reference – operations are performed on the referenced value, not the reference.
Accesses are e.g.:
ref.field
orref.func()
ref[0]
这一点很难解释,但是在我的理解中:参考只是对象的代理。
因此,当您实际调用
getType()
时,实际上是在引用对象上调用它。This one is little hard to explain, but in my understanding: references are just proxies to the object.
So when you actually call
getType()
, you are actually calling it on the referenced object.