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?
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]