discard self
★★★- ownership
- noncopyable
Swift 6.3.2 Report an issue
Verified quizzes have their expected answer checked by compiling and running the code with the listed Swift toolchain during the site build.
struct H: ~Copyable {
consuming func finalize() {
print("saved"); discard self
}
deinit {
print("deinit")
}
}
H().finalize()
Hint
What's discard self for, and how does it relate to a noncopyable type's
deinit?