All Downloads are FREE. Search and download functionalities are using the official Maven repository.

reference.language.category_methods_overriding.html Maven / Gradle / Ivy




    
    Methods
    
    

    
    

    
    

    
    
    
    

    


Overriding category methods

When a category implements a method, it can be handy to override that method in derived categories.

This is done simply by providing inside the derived category definition a new version of the method defined in the parent category.

In the below example, we:

  • define an 'Animal' category with a 'speak' method
  • define an 'Dog' category, derived from 'Animal', which overrides the 'speak' method
  • define an 'Cat' category, derived from 'Animal', which overrides the 'speak' method
  • call the 'speak' method for an instance of each of them





© 2015 - 2025 Weber Informatics LLC | Privacy Policy