O'Reilly logo

Kotlin Programming: The Big Nerd Ranch Guide, First Edition by David Greenhalgh, Josh Skeen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Anatomy of a Function

Figure 4.3 shows the two primary parts of a function, the header and body, using formatHealthStatus as a model:

Figure 4.3  A function consists of a function header and a function body

A function consists of a function header and a function body

Function header

The first part of a function is the function header. The function header is made up of five parts: the visibility modifier, function declaration keyword, function name, function parameters, and return type (Figure 4.4).

Figure 4.4  Anatomy of a function header

Anatomy of a function header

Let’s look at each of those ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required