Skip to content

Instantly share code, notes, and snippets.

@NikolajMosbaek
Created June 1, 2022 15:03
Show Gist options
  • Save NikolajMosbaek/eaa72c71227ed10e9c1e1b4eddcf679d to your computer and use it in GitHub Desktop.
Save NikolajMosbaek/eaa72c71227ed10e9c1e1b4eddcf679d to your computer and use it in GitHub Desktop.
This code will func a function on every value on any object
func mirror(_ value: Any, using function: (Any) -> Void) {
let mirror = Mirror(reflecting: value)
for child in mirror.children {
function(child.value)
}
}
@NikolajMosbaek
Copy link
Author

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