官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 福建省| 兴山县| 扶绥县| 衡东县| 天柱县| 旬邑县| 佛坪县| 阳东县| 大化| 平罗县| 岳阳县| 汶上县| 霸州市| 大厂| 宝丰县| 依安县| 武川县| 玉门市| 长葛市| 东乌| 泰宁县| 清涧县| 文水县| 海淀区| 恩施市| 瑞昌市| 高陵县| 山东省| 措勤县| 方正县| 崇左市| 韩城市| 察雅县| 怀来县| 准格尔旗| 公安县| 庄浪县| 大化| 应城市| 聊城市| 北碚区|