diff options
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/user-guide/06-interfaces-generics.md | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/docs/user-guide/06-interfaces-generics.md b/docs/user-guide/06-interfaces-generics.md index b90bc04ba..1912fcb02 100644 --- a/docs/user-guide/06-interfaces-generics.md +++ b/docs/user-guide/06-interfaces-generics.md @@ -43,8 +43,21 @@ struct MyType : IFoo, IBar uint myMethod2(uint2 x) {...} } ``` + In this case, the definition of `MyType` must satisfy the requirements from both the `IFoo` and `IBar` interfaces by providing both the `myMethod` and `myMethod2` methods. +Interface methods can have a default implementation, which will be used if a conforming type doesn't provide an overriding implementation. For example: + +```slang +interface IFoo +{ + int getVal() { return 0; } +} + +// OK, MyType.getVal() will use the default implementation provided in `IFoo`. +struct MyType : IFoo {} +``` + Generics --------------------- |
