you are viewing a single comment's thread
view the rest of the comments
[–] 1 point 3 years ago (1 child)

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

  • source
  • parent
  • hideshow 2 child comments
  • [–] [S] 2 points 3 years ago (1 child)

    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.

  • source
  • parent
  • hideshow 2 child comments