Abstract methods: pattern

Yes, that’s possible and widely used. You should explicitly add methods to general.weight:

general.weight(::apple)=0.2
general.weight(::lemon)=0.1

It is also possible to import general.weight into specific’s namespace, but that’s not recommended in order to avoid unintentional overloads.

Also, please follow the naming guidelines to make your code easier to read for others.

1 Like