Should b not be let? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Should b not be let?

Variable b should be made a constant since it never changes Hence let b = value Alternatively the answer should accept both let and var in the declaration of b.

10th Jul 2019, 8:04 PM
Sashen Pillay
Sashen Pillay - avatar
7 Answers
+ 1
in what context?! 😅😅
10th Jul 2019, 8:09 PM
Anton Böhler
Anton Böhler - avatar
+ 1
did the question not attach the quiz?
10th Jul 2019, 8:11 PM
Sashen Pillay
Sashen Pillay - avatar
+ 1
The question asked something similar to
10th Jul 2019, 8:11 PM
Sashen Pillay
Sashen Pillay - avatar
+ 1
swift
10th Jul 2019, 8:12 PM
Sashen Pillay
Sashen Pillay - avatar
+ 1
var a = 10 __ b = 30 let sum = a + b print(sum)
10th Jul 2019, 8:14 PM
Sashen Pillay
Sashen Pillay - avatar
+ 1
the question asked to fill in the blank but wouldnt accept let as an answer
10th Jul 2019, 8:15 PM
Sashen Pillay
Sashen Pillay - avatar
+ 1
If that was your only code, your version would work since 30 is the only number b is. However, this code is meant to be reusable as you will see if you continue in Swift. Other parts of the program would be able to change "b" and return a different sum (the whole point in using variables). B should be a var. Otherwise you may as well just type: print(10 + 30) or even just print(40)
11th Jul 2019, 12:05 AM
Frenchtoast
Frenchtoast - avatar