-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Borrow function in NFT Docs #895
Conversation
In function borrowNFT_ NonFungibleToken type cast to `&{NFT}?` is redundant. To remove this error added Force Unwrap Operator (!).
@DappCoderr is attempting to deploy a commit to the Flow Team on Vercel. A member of the Team first needs to authorize it. |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, thanks for the correction!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is correct. This function is supposed to return an optional, so we should not be force unwrapping it here. See ExampleNFT for the correct implementation.
@DappCoderr Can you explain what you're trying to do here? Maybe I'm not understanding
I understand that the value should be returned as optional. However, when I use it, I encounter the compilation error "cast to &{NFT}? is redundant." To resolve this, I've added the force unwrap operator (!). |
That isn't an error, it is just a warning, so the contract will still deploy if you ignore it. That is just pointing out that the entire cast is redundant, not the
Can you update the PR to just have that? Thank you! |
Thanks for the clarification, @joshuahannan |
Removing the cast to &{NonFungibleToken.NFT} as it's redundant and introduces potential warnings.
In the Collection resource borrowNFT_ function gives an error.
NonFungibleToken type cast to
&{NFT}?
is redundant.Solution: To remove this error add Force Unwrap Operator (!).