• snaggen@programming.dev
      hexagon
      ·
      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.

        • snaggen@programming.dev
          hexagon
          ·
          1 year ago

          Traits are similar to an interface, but with some differences. Here is a comparison with Java interfaces https://stackoverflow.com/a/69485860