What Kotlin Does (and When)
IN THIS CHAPTER
Making decisions with Kotlin statements
Repeating actions with Kotlin statements
Adding exception handling
Human thought centers on nouns and verbs. Nouns are the “stuff,” and verbs are the stuff's actions. Nouns are the pieces, and verbs are the glue. Nouns are, and verbs do. When you use nouns, you say, “book,” “room,” or “stuff.” When you use verbs, you say “Do this,” “Do that,” “Hoist that barge,” or “Lift that bale.”
Kotlin also has nouns and verbs. Kotlin’s nouns include
Array, along with Android-specific things such as
Bundle. Kotlin’s verbs involve assigning values, choosing among alternatives, repeating actions, and other courses of action.
This chapter covers some of Kotlin’s verbs. In Chapter 5 of this minibook, you bring in the nouns.
Making Decisions (Kotlin if Statements)
When you’re writing computer programs, you’re constantly hitting forks in roads. Did the user correctly type his or her password? If yes, let the user work; if no, kick the bum out. So the Kotlin programming language needs a way of making a program branch in one of two directions. Fortunately, ...