Hacker News new | past | comments | ask | show | jobs | submit login

In Raku those things are also separate.

1. Polymorphism

    class Example {
      method be-nice () {
        'be nice'
      }
    }

    class Bill-and-Ted is Example {
      method be-nice () {
        'be excellent to each other'
      }
    }
2. Composition

    role Salaried {
      has $.salary;
    }

    role Employee {
      has $.title;
    }

    class Manager does Employee does Salaried {}
3. Delegation

    class Price {
      has $.cost;
    }

    class Product {
      has Price $.inner handles( 'price' => 'cost' );
    }
Any call to the `.price()` method on `Product` will delegate to the `.cost()` method on the inner object.



Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: