From the course: Build Spring Boot Apps with the Kotlin Programming Language

Unlock this course with a free trial

Join today to access over 22,500 courses taught by industry experts.

Using named parameters and optional parameters

Using named parameters and optional parameters

- Now let's take this a step further and to do that I want a slighter bigger function. And I think we'll call this one print some maths. If you're watching this and you're an American then in Britain we use the word maths as short for mathematics, I know you use math, so if you'd prefer to call it that then do, that's absolutely fine. I want to provide two values again, so let's call them one and two. And again they're both going to be doubles. But this time I want to do a couple of different things. So we're going to make this a standard function and there's no return for this, it's a unit, so I don't need to put in my colon unit but what I'd like to do is maybe add them up and subtract them and print out the results. So let's print out one plus two is. We'll use the dollars, curly brackets expression here to evaluate one plus two and then let's do the same thing on the next line down but we'll do one minus two. And let's run that function with our same two numbers. So we'll call…

Contents