Open turbolent opened 3 years ago
It may be worth explicitly noting that return values are copied.
I have an example for that here:
And here's an example for the pub const gotcha:
https://play.onflow.org/3ca9083a-4662-48ec-8211-c636ac25e88d?type=account&id=0
On the access control page, add "Remember that if you can access a let dictionary or array you can mutate its contents, this includes when they are pub or access(all) member variables of a contract, resource or struct."
@rheaplex It's documented that it's pass-by-value, but we should make that more prominent / add it as an example / detail, agreed 👍
@rheaplex also, @bluesign had the great idea to report a warning, I've opened onflow/cadence-tools#429 for that
Various topics should be added or improved:
Tasks:
Todos:
getAccount
andgetAuthAccount
math/rand
nil
is a NO-OP. An optional is a single-element container, and if it has no value, there is nothing to do. Just like destroying another container, like an empty array or empty dictionaryload
ing just to destroy the value, useAnyResource
/AnyStruct
instead of a specific type, as it may be incorrect, in which caseload
will returnnil
Array.contains
log