N
N
No Name2018-07-28 19:17:35
Kotlin
No Name, 2018-07-28 19:17:35

Kotlin: is there an analogue of the type operator from Typescript?

To set a limited list of string values ​​in Typescript I do this

type Modes = 'simple' | 'medium' | 'advanced';
class Car {
    name: string;
    mode: Modes; // компилятор будет ругаться, если значение будет отличаться от перечисленных, и это хорошо
}

How to do the same in Kotlin?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
1
1001001, 2018-07-28
@1001001

https://kotlinlang.org/docs/reference/enum-classes.html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question