Skip to content

Commit

Permalink
use conditional downcasting
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuahannan committed Jan 24, 2024
1 parent 324e2e3 commit 5a1cf77
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions contracts/utility/Burner.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ access(all) contract Burner {
/// If the provided resource implements the Burnable interface,
/// it will call the burnCallback method and then destroy afterwards.
access(all) fun burn(_ r: @AnyResource) {
if let s <- r as @{Burnable} {
if let s <- r as? @{Burnable} {
s.burnCallback()
destroy s
} else if let arr <- r as @[AnyResource] {
} else if let arr <- r as? @[AnyResource] {
while arr.length > 0 {
let item <- arr.removeFirst()
self.burn(<-item)
}
destroy arr
} else if let dict <- r as @{HashableStruct: AnyResource} {
} else if let dict <- r as? @{HashableStruct: AnyResource} {
let keys = dict.keys
while keys.length > 0 {
let item <- dict.remove(key: keys.removeFirst())!
Expand Down
6 changes: 3 additions & 3 deletions lib/go/contracts/internal/assets/assets.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5a1cf77

Please sign in to comment.