Posts

Showing posts with the label conditions

Collections and Control Flow - Conditional Statements

Next - and final - part of Control Flow is all to do with 'conditionals'. This will be linked to 'if' statements. These are a vital part of Swift and hopefully I'll be able to remember some! After that, the course is complete, which means I can crack on with 'functions' next...! If Statements var temperature = 22 if temperature < 18 {          print ( "Wear a light sweater" )      } else {          print ( "No need for a sweater!" ) } A very simple example! I remembered the 'else' clause. This is when the statements evaluate to 'false'.  In the above example, the code runs through to the 'else'/false statement and prints the second line ("No need..."). However, if I made the the temperature higher than 18, then the other statement would. The other aspect of this is using 'else if', which means another condition!  var temperature = 22 if temperatur...