https://kotlinlang.org logo
Title
l

LastExceed

08/14/2019, 9:56 AM
is
import MyClass as SomeType
the same as
import MyClass
typealias SomeType = MyClass
?
g

gildor

08/14/2019, 9:58 AM
no, it’s a bit different
l

LastExceed

08/14/2019, 9:58 AM
can you explain?
g

gildor

08/14/2019, 9:58 AM
typealias becomes available to other files, they can use in declarations etc
d

diesieben07

08/14/2019, 9:58 AM
No. An aliased import is local to that file. A typealias can be imported in other files, just like a class:
// A.kt
typealias Foo = Bar

// B.kt
import Foo
l

LastExceed

08/14/2019, 9:58 AM
ah i see, thanks
g

gildor

08/14/2019, 9:58 AM
import MyClass as SomeType is just rename some member (class, function) for this file
d

Dico

08/14/2019, 10:10 AM
And a typealias is a duplicate symbol, not a rename
l

LastExceed

08/14/2019, 10:10 AM
so if i use
typealias
i could still use the original name but i cannot do that if i use
import as
?
:yes: 3