So, you can only use a switch to perform an action when one specific variable has a certain precise value. Bitwise operations are represented by functions that can be called in infix form. They operate on the binary level directly with bits of the numbers representation. Plus LocalTime s use a limited range of values, from MIN to MAX, so you can avoid doing comparisons like testTime < 25.00. However it cannot replace all sort of if/else sequences but just those which compare a value with some constant. Kotlin provides a set of bitwise operations on integer numbers. 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. Kotlin is full of these pragmatic improvements, getting its user a language that just feel good to use. 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. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |