Creating a Boolean

Now, it is time to create a Bool. Let's make it a constant. Enter the following code:

let isConstant:Bool = true

This is demonstrated in the following screenshot:

Since isConstant is set, let's make it false by adding this:

isConstant = false

On the same line as what you just entered, you will now see a red circle with a white dot in the middle. The red circle means that there is an error. The white circle inside of it indicates that Xcode can fix the error for you (most of the time):

You will also notice an error in your Debug Panel, which is just a more detailed version of the error. This error is telling us that we are trying to change the value of a constant when we cannot do so.

If you tap on the circle, you will see that Playgrounds suggests that you change the let to a var since you cannot assign a value to a constant:

Since we want it to remain a constant, let's delete the line isConstant = false. We have covered basic data types, but there are some other programming basics we should discuss as well.

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

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