So, you can only use a switch to perform an action when one specific variable has a certain precise value. However it cannot replace all sort of if/else sequences but just those which compare a value with some constant. ![]() One of the most useful improvement, especially if you come from Java, is the when construct.Ī traditional switch is basically just a statement that can substitute a series of simple if/else that make basic checks. You can use Kotlin's slice function to get a part of the list by passing the range of indices. CharProgression is a subclass of Iterable and the plus operator is defined on iterables: Iterable.plus Yeilding a very simple looking and obvious ('a'.'z') + ('A'.![]() Kotlin is full of these pragmatic improvements, getting its user a language that just feel good to use. The returns a CharRange that is an implementation of CharProgression. There are two kinds of innovation: new perspectives that changes how we look at things and pragmatic improvements that changes how we do things.
0 Comments
Leave a Reply. |