December 2017
Intermediate to advanced
260 pages
7h 34m
English
Unlike any other programming languages, Kotlin also has a primary/default and secondary constructor. The primary/default constructor is a part of the class header itself. Consider the following code snippet:
class SectionsPagerAdapter(fm: FragmentManager) : FragmentPagerAdapter(fm)
Here see how we pass the object directly to the superclass. No explicit super call is required. For example, super(someParam), no such code is required.
The problem with this approach is you cannot access those parameters in the class, that is, fm cannot be used in the class. But if you want to use that parameter in the class, Kotlin has a syntax. For that refer to our other class TweetAdapter. There we want to use items and the callback methods inside ...
Read now
Unlock full access