Using common data types in the playground

Now that you know about Swift's implementation of these common data types, let's use them in the playground we created. Perform the following steps:

  1. Type the following code into the Editor area of your playground and click the Play/Stop button when done:
// Examples of integers 
42
-23

// Examples of floating-point numbers
3.14159
0.1
-273.15

// Examples of booleans
true
false

// Examples of strings
"hello, world"
"albatross"

Note that any word with // in front of it is a comment. Comments are a great way to create notes or reminders to yourself and that will be ignored.

  1. Wait a few seconds. You should see the values displayed in the Results area.

Cool! You have just created and run your first playground. Let's look at how to store different data types in the next section.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.220.1.239