weight = Weight1() } public static func exercise1_1() -> Exercise1_1 { let x = Exercise1_1() x.value = x return x } ॥ࢀরΛͭ͘Δ άϥϑͷมԽΛΘ͔Γ͘͢ ͢ΔͨΊͷେ͖ͳΦϒδΣΫτ 25
weight = Weight2() } public static func exercise1_2() -> Exercise1_2 { let x = Exercise1_2() x.value = x return x } ॥ࢀরΛͭ͘Δ άϥϑͷมԽΛΘ͔Γ͘͢ ͢ΔͨΊͷେ͖ͳΦϒδΣΫτ 36
weight = Weight3() } public static func exercise1_3() -> Exercise1_3 { let x = Exercise1_3() x.value = x return x } ॥ࢀরΛͭ͘Δ άϥϑͷมԽΛΘ͔Γ͘͢ ͢ΔͨΊͷେ͖ͳΦϒδΣΫτ 47
= Exercise2() var values = [Any]() values.append(Weight2() as Any) for _ in 0..<100 { values.append(Exercise2()) } let y = Indirect() values.append(y) y.value = ["y": x] for _ in 0..<100 { values.append(Exercise2()) } x.value = values return x άϥϑͷมԽΛΘ͔Γ͘͢ ͢ΔͨΊͷେ͖ͳΦϒδΣΫτ ॥ࢀরΛՃ ແؔͳࢀরΛͨ͘͞ΜՃ ແؔͳࢀরΛͨ͘͞ΜՃ 52
= Exercise3() let y = Indirect() x.value = y var prev = y for _ in 0..<100 { let z = Indirect() prev.value = z prev = z } prev.value = x େͳ॥ࢀরύεΛઃఆ 54
weight = Weight2() public class Indirect: CustomReflectable { var value: Any? public var customMirror: Mirror { return Mirror(self, children: []) } } .JSSPS SF fl FDUJOH Ͱ ԿTUPSFEQSPQ͕ ͳ͍ͱࡨ֮ͤ͞Δ 70