faking with protocols in swift.
protocol Machine {
func value() -> Self
}
//struct that returns itself
struct Fun:Machine {
var elem:Int
func value() -> Fun {
return self;
}
}
//struct that returns itself
struct string:Machine {
var elem:String
func value() -> string {
return self;
}
}
var storage = [Machine]()
storage.append(Fun(elem:4))
storage.append(string(elem:"fooo"))
let tester = storage[0].value()