abstract_type.sf 408 B

1234567891011121314151617181920
  1. #!/usr/bin/ruby
  2. class A {
  3. # must be filled in by the class which will inherit it
  4. method abstract() { ... };
  5. # can be overridden in the class, but that's not mandatory
  6. method concrete() { say '# 42' };
  7. }
  8. class SomeClass << A {
  9. method abstract() {
  10. say "# made concrete in class"
  11. }
  12. }
  13. var obj = SomeClass.new;
  14. obj.abstract(); # made concrete in class
  15. obj.concrete(); # 42