• mrsgreenpotato
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 year ago

    What’s a good alternative to inheritance in your Animals example?

    • snaggen@programming.devOP
      link
      fedilink
      arrow-up
      2
      ·
      1 year ago

      If you look at Rust for example, then you specify the Traits instead. So, you could define a trait that defines the properties for birth, another to define if the animal have a beak, and another one to define the number and type of legs. The each animal implement these traits, which then properly can define a duck, cat and a platypus.