Extending Types
Extending base types with custom methods is easy and allows for some powerful extensions. To start, you need to use the ext
keyword and then the base type that you would like to extend. Use curly braces to signify that you want to add methods and then define your methods within them.
Example
Let us take a look at an example, to extend an integer with a method to double its value.
Last updated