import Foundation protocol SomeProtocol { associatedtype Thing func doSomething() } struct SomeStruct:SomeProtocol { let thing:Thing func doSomething() { print( "=> \(thing)" ) } } struct SomeClass { var someThing:any SomeProtocol func run() { self.someThing.doSomething() } } let someStructInstance1 = SomeStruct(thing:"What is the answer to the ultimate question?") let someStructInstance2 = SomeStruct(thing:42) let someStructInstance3 = SomeStruct(thing:someStructInstance1) let someStructInstance4 = SomeStruct(thing:someStructInstance2) let someStructInstance5 = SomeStruct(thing:[someStructInstance1,someStructInstance2,someStructInstance3,someStructInstance4]) var someClassInstance = SomeClass( someThing:someStructInstance1 ) someClassInstance.run() someClassInstance.someThing = someStructInstance2 someClassInstance.run() someClassInstance.someThing = someStructInstance3 someClassInstance.run() someClassInstance.someThing = someStructInstance4 someClassInstance.run() someClassInstance.someThing = someStructInstance5 someClassInstance.run() /* Output: => What is the answer to the ultimate question? => 42 => SomeStruct(thing: "What is the answer to the ultimate question?") => SomeStruct(thing: 42) => [__lldb_expr_24.SomeStruct(thing: "What is the answer to the ultimate question?"), __lldb_expr_24.SomeStruct(thing: 42), __lldb_expr_24.SomeStruct<__lldb_expr_24.SomeStruct>(thing: __lldb_expr_24.SomeStruct(thing: "What is the answer to the ultimate question?")), __lldb_expr_24.SomeStruct<__lldb_expr_24.SomeStruct>(thing: __lldb_expr_24.SomeStruct(thing: 42))] */