Skip to content

simple inheritance  #111

@robaho

Description

@robaho

Is there any way to do this?

@Codable
class A {
   var name : String
}
@Codable
class B : A {
   var location : String
}

@Codable
class Container {
    var elements[A] = [ B() ]
}

How do I annotate this so that when Container is decoded the correct instances of A/B are instantiated?

I got dynamic coding with a protocol working but I'd rather not use that. It seems it only works with protocols and enums?

I could code it by hand to work, but it seems the purpose of MetaCodable is to make something like this easy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    invalidThis doesn't seem right

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions