RosettaCodeData/Task/Break-OO-privacy/Swift/break-oo-privacy.swift
2019-09-12 10:33:56 -07:00

11 lines
261 B
Swift

struct Example {
var notSoSecret = "Hello!"
private var secret = 42
}
let e = Example()
let mirror = Mirror(reflecting: e)
if let secret = mirror.children.filter({ $0.label == "secret" }).first?.value {
print("Value of the secret is \(secret)")
}