i get a lot of error’s when trying to study Swift.
I used the code that i practised in the Magic 8 Ball project from the iOS Developer Career Path, but i get a lot of error’s (already tried to change some of the ‘let’ to ‘var’, but seems to still have error’s) What am i doing wrong here? anyone has some advice?:
Here are a few things to consider:
- If you want to declare
eightBall
as a constant variable without initialization, then you should use:
let eightBall: String
If it doesn’t need to be a constant, you could do:
var eightBall = ""
- Your cases are numbers, so your switch expression should also be a number.
// You wrote:
switch eightBall {
case 1:
...
// Change it to:
switch randomNumber {
case 1:
...
- You also have typos in your print statements. You wrote
\(playername)
instead of\(playerName)
and\(eighBall)
instead of\(eightBall)
1 Like