Kotlin type aliases (#31846)

* Kotlin type aliases

* fix/folder-name
This commit is contained in:
Ian Myrfield
2019-07-07 17:14:08 -07:00
committed by Tom
parent f75e20a969
commit 6f78106a43

View File

@ -0,0 +1,32 @@
---
title: Type Aliases
---
# Type Aliases
A type alias is a way to provide an alternative name to an existing type. This can be helpful when an existing type has a long name. It's important to note, Type aliases do not introduce new types. They still equate to their original, underlying types.
### Basic Usage
```kotlin
typealias LocalUsers = List<User.LocalUser>
```
You can also create type aliases for function types.
```kotlin
typealias ValidUsername = (String) -> Boolean
```
And for inner & nested classes.
```kotlin
class Foo {
inner class Bar
}
class Baz {
inner class Bar
}
typealias FBar = Foo.Bar
typealias BBar = Baz.Bar
```