Posts

Showing posts with the label Syntax

Constants; Conventions and Rules; Strings

With renewed vigour, I'm restarting my Swift journey, going over familiar ground! This has happened before, as it's comforting and easy to go through information I already know. However it is necessary and important. Along with the Treehouse tutorial videos, I've found another eBook 'App Development with Swift', which I'll use to supplement and check any of the key points.  Swift Basics Video 4: Constants The analogy he makes here is that computers are not smart enough to figure out if something has changed. The purpose of constants is to create a value that will NEVER be changed. We can see what is inside the box (the glass box analogy!) but CANNOT change it! let language = "Swift" This is a simple example to show how a constant is created. If we try to change the value of 'language', then there will be errors! This is because it is a constant. Makes total sense. Xcode will show the 'red error' with the icon, which will the...

What I know about Swift - Part Three

This is likely to be the last post about my understanding of Swift - at this point in my journey. After this, thoughts and reflections will be "live", in the sense that they will be specifically about what I have just discovered, am trying to make clearer to me, or feel compelled to share. As before, I am not claiming that ANY of this information is technically correct or accurate; it is what I understand about Swift, at present! Enumerations and Switch I've lumped these together on the premise that Switch statements can be used within Enumerations; both use cases so there is a link there. Switch could actually have been part of the Conditionals - if/else etc. var score = 54 var comment: String = "" switch score {      case 0 ... 20 :     comment = "Good score!"      case 21 ... 50 :     comment = "Great score!"      case 50...100 :     comment = "Excellent score!" ...