What is the purpose of a ‘for’ loop? I can choose multiple but according to what I’ve read via the swift book, its used to iterate through items in an array or list.
But....does it have other uses?
which of these would allow you to control the flow of your application based on a case from the following enum? multiple could apply
enum Language {
case swift
case objectiveC
case rust
case ruby
}
A) if
B) switch
C) for loop
D) protocol i think it’s loop only, which makes me nervous to press submit
this one is frustrating because I know once it’s explained I’ll feel silly -
Which is the correct way to write a string that reads “the width is 100”
I said —
let widthLabel = “The width is \ (100)”
I’m right, right?
Hi, not homework. I’m self teaching and doing coding challenges online. As you can see, I did say what I was thinking the correct responses were as well under each question I had. I’ve been reading and learning and trying to receive some help or be pointed in the right direction for more help. Thank you
for _ in 0..<1_000_000 {
sendMoneyToMyBankAccount()
}
if language == .swift {
sendMoneyToMyBankAccount()
}
switch language {
case .swift:
sendMoneyToMyBankAccount()
case .objectiveC:
break
case .rust:
break
case .ruby:
break
}
Coding challenges will only take you so far. You really just need to write code until it becomes second nature. Once you are proficient, you need to learn about programming patterns to write larger programs. Finally, you need to learn about the engineering side of programming to make sure you are choosing the right patterns for performance. There is no shortcut. Read all you can. Don’t worry if you don’t understand it all at first. Take breaks and revisit topics you don’t fully understand. Each time it will make more sense until you get it. See what others are doing in their code and try to figure out why they are writing the way they do.