Skip to content

Instantly share code, notes, and snippets.

@shaps80
Created January 11, 2024 12:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shaps80/11bada4db1813180a0880b6b33003168 to your computer and use it in GitHub Desktop.
Save shaps80/11bada4db1813180a0880b6b33003168 to your computer and use it in GitHub Desktop.
Mirror: Print recursively
extension Mirror {
func printRecusively() {
for child in children {
let label = child.label ?? "<unknown>"
let value = child.value
print(type(of: value), label, value, separator: " | ")
Mirror(reflecting: value)
.printRecusively()
}
}
}
@shaps80
Copy link
Author

shaps80 commented Jan 11, 2024

Usage:

Mirror(reflecting: self).printRecursively()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment