+ 1

Help

Need help wothlesson Q2 varialbles

29th Apr 2019, 8:03 AM
Josh
2 Answers
+ 9
Josh Can you please attach the quiz question too in question for receiving meaningful answer, or link the lesson and topic which you are referring to. please take care in future to include the topic and proper description towards your query.
29th Apr 2019, 8:21 AM
GAWEN STEASY
GAWEN STEASY - avatar
+ 5
In Swift, variables are declared using the var keyword. var a = 3 A variable can hold various data. This includes numbers, words, single characters, etc. When the variable is declared (in other words, created), you can assign a value to it using its name. var b = 1 b = 4 b = 3.142 ---- In Swift, we use let to create constants. When a constant is created, you can't change the value. let π = 3.142 // Yes, the name is valid Note: When declaring a constant, you need to assign a value. If you try and change the value, you will get an error let π = 3.142 π = 3.14259 // Error ----- Naming variables -------------------------- In Swift, you may name your variables using: - Any letter - Underscore ( _ ) - Any number as long as the number appears after the first character - π Here are examples of valid names: π a A a3 a_3 aH3 Here are Invalid names 3a .a 3.a 3$a 2*a #a
29th Apr 2019, 8:22 AM
Edwin Pratt
Edwin Pratt - avatar