Learn Courses My Dashboard

Beginner question - what can you let a Constant be equal to?

I’m working through Learn to Code 1 and 2 in Swift Playgrounds, as my endeavour to learn to code for the Max has been limited by the fact that my Max is too old for me to download Xcode.

Could somebody please explain to me what I would write this line of code? I have been coding for a few days (other than Scratch with my kids, this is the first language I have ever tried to learn to code in) and have done the first lesson in Swift Playgrounds that mentions constants, and have now moved onto the second one (Three Gems, Four Switches), but I don’t understand why this would be written.

Let switchCounter = numberOfSwitches

In other peoples answers written online, no one even mentions numberOfSwitches again, so I don’t understand where it has been plucked from.

I expected a Constant to be an integer, and in this lesson, the number of switches will be constant, but the switch counter should surely be a variable. I don’t know why you would write “let a variable equal a constant”

I would have expected the code in this lesson to begin with eg let numberOfSwitches equal 4, so can someone help me explain what that line means and why it needs to be included?

Thanks in advance.

Actually, this is on the lesson: “Checking for equal values”

Hello @flashduncan can you point me directly on what course, Module and lesson no. where I can find the lesson you’re referring to?

for example:

I want to check so that I can explain it to you using the same example used on the video. :blush: