January 2018
Intermediate to advanced
434 pages
14h 1m
English
In the following steps and examples, we will see how we can disambiguate classes of the similar name using Kotlin's keyword.
import foo.Bar // Bar is accessibleimport bar.Bar as bBar // bBar stands for 'bar.Bar'
Bar.methodOfFooBar()bBar.methodOfBarBar()
For example, let's see the use of the as keyword to disambiguate two classes having the same name (SomeClass.kt), but in different packages:
SameClass.kt (packageA)
package packageAclass SameClass { companion object { fun methodA(){ println("Method a") } }}
SameClass.kt (packageB)
package packageBclass SameClass ...
Read now
Unlock full access