Objects Expressions and Declarations
Explore the concept of objects in Kotlin, including object expressions and declarations, and learn how they are used to create unique instances.
We'll cover the following...
Introduction to objects
An object is an instance of a class, and one common method of creating objects is using constructors:
class A// Using a constructor to create an objectval a = A()
Creating an instance of class A using a constructor
However, this is not the only way. In Kotlin, we can also create objects using:
Object expression
Object declaration
Object expressions
To create an empty object using an expression, we use the object
keyword and braces. This syntax ...