As example I have struct/class:
struct Pet {
var id: String
var name: String
var age: Int
var type: PetType
}
enum PetType: Int {
case cat
case dog
}
Is it possible to write extension to COPY SET OF PARAMETERS from one object to another?
Sth like:
var pet1 = Pet(id: "MyCat1", name: "Cookie", age: 4, type: .cat)
let pet2 = Pet(id: "randomCatId", name: "Socks", age: 3, type: .dog)
pet1.copy(from: pet2, keys: [.name, .age, .type] )
// after this pet1 will be:
// ("MyCat1", "Socks", 3, .cat)
// instead of
// ("MyCat1", "Cookie", 4, .cat)
if it is not possible, what is the best way copy from one object to another large set of parameters?