Chapter 4

What Kotlin Does (and When)

IN THIS CHAPTER

check Making decisions with Kotlin statements

check Repeating actions with Kotlin statements

check 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 String, List, and Array, along with Android-specific things such as AppCompatActivity, ActionBar, and 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, ...

Get Android Application Development All-in-One For Dummies, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.