October 2018
Intermediate to advanced
370 pages
9h 15m
English
An interface is somewhat similar to an abstract class in that it provides a list of functions to implement. An interface is basically a contract between classes in which each class has to provide an implementation of the functions that are defined in the interface. An interface is declared with the interface keyword. Let's take a look at an example:
interface interface_name{ fun func1() fun func2() }interface IPrintable { fun print()}
Creating an interface is similar to creating a class. The names of the interfaces start with the letter I. This is not a syntax requirement, but a common practice to differentiate between classes and interfaces because their syntax is similar:
class Invoice : IPrintable { override fun print() { ...Read now
Unlock full access