Learning Kotlin: Type Aliases

Type aliases in Kotlin allow you to provide alternative names for existing types. This is particularly useful for shortening long type names, or for providing more semantic meaning to existing types.

For example, instead of using ‘String’ you could create a type alias called ‘UserId’ that provides more information about the expected usage of that type.

šŸ’» Examples:

'typealias UserId = String'

You can then substitute ‘UserId’ where you would otherwise use ‘String’. To the compiler, they both are treated the same.

šŸ“š Reference:

Thoughts, questions, tips on type aliases in Kotlin? Comment below or share on social media. Iā€™d love to continue the conversation.


I love to meet/talk/discuss and help where I can. If you want to chat or ask a question you can follow me on Twitter, YouTube, Instagram and Facebook.

Check Out My YouTube Channel

Leave a Reply