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.



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

Search: