https://kotlinlang.org logo
#announcements
Title
# announcements
a

adolev

06/05/2017, 9:25 AM
Hello, when I declare a typealias, am I supposed to be able to discriminate between the alias and the aliased type in a when expression?
a

Andreas Sinz

06/05/2017, 9:43 AM
adolev: There is no way to determine whether its the typealias or the type itself. if you have a
typealias UserName = String
, you can pass a
String
when a method expects a
Username
"Type aliases do not introduce new types. They are equivalent to the corresponding underlying types." says the doc
a

adolev

06/05/2017, 9:46 AM
OK, thanks! I was just wondering, if it was the case, how the type information was retained at runtime. This makes it a lot simpler 🙂
2 Views