In Kotlin, the constructor is same as other programming languages, it is a special kind of member function that is invoked when an object is being created and it is primarily used for initializing the variables or properties.
Here is the syntax to create a new instance of the Triple:
Triple(first: A, second: B, third: C)
In the below examples, we will create a triple by using the constructor.
Example 1:
Output:
Example 2:
Output:
need an explanation for this answer? contact us directly to get an explanation for this answer