From the course: Make SwiftUI Playgrounds Applications

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Formatted numbers

Formatted numbers

- [Instructor] We've learned about the difference between numbers and strings, that they don't play well together, and how to use interpolation to get them to behave. However, interpolation doesn't always work nicely. So we're going to open up a new playground file, and that's the one with the rectangle. And we can open that up, go into it. And you get a nice blank page here. So we're going to enter some code here. So I'm just going to tap to enter code. And so we're going to start with import and then foundation. And that adds a library of standard classes and methods that will come in handy, most importantly our formatters. And then underneath that I'm going to make a constant pi. I'm going to go ahead and use this print statement here. And print works the same way as text, except that it takes anything. Instead of only taking strings, it can take numbers as well, like I did here. All right, and with all that I can tap run…

Contents