m = Mirror(reflecting: value) if m.displayStyle == .struct { var result = [String:Any]() for case let (label?, value) in m.children { result[label] = gen(value: value) } return result } else { return value } }
value) if m.displayStyle == .struct { var result = [String:Any]() for case let (label?, value) in m.children { result[label] = gen(value: value) } return result } else { return value } }
[PersistentObject] // this is NOT what I want ^ extension Collection where Iterator.Element == PersistentObject { } // var list: [SomeTypeThatImplementsPersistentObject] //e.g // var list: [Addresses] // this is what I want for PersistentObject^
func fib(_ i: Int) -> [Int] { if i == 0 { return [0] } else if i == 1 { return [0, 1] } else { let seq = fib(i-1) let c = seq.count let next = [seq[c-2] + seq[c-1]] return seq + next } }