Inheritance
Inheritance is defined using the is
argument to contract
:
This causes all of ERC721's and Ownable's functions, events, and state variables to be merged into Child
.
Virtual and Override Modifiers
When a contract inherits from another, Rubidity automatically merges functions from parent contracts. If both parent and child contracts have a function with the same name, the child's function will override the parent's function, provided that the parent function is marked as virtual
and the child's function is marked as override
.
For example, a typical ERC721 parent contract transferFrom would be marked virtual:
Which would allow a child to override it like this:
Calling Parent Functions
In Rubidity there is no super. Instead, parent functions are called as methods on the parent contract constant, as above:
Parent constructors work in the same way as normal parent functions, for example:
Last updated