Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

please help with these swift questions I will thumbs up in rating !!! 1. String,

ID: 3918145 • Letter: P

Question

please help with these swift questions

I will thumbs up in rating !!!

1. String, Array, and Dictionary are implemented as structures in Swift.

A) True
B) False

2. Given the following Swift code:

var age: Int? = 20
if let age = age {
print(age)
}

For the line "if let age = age {", which of the following is true?

A) If age on the right of the = is not nil, then the age on the left of the = is the unwrapped value of age.
B) If age on the right of the = is nil, then the code in the if statement executes.
C) The age on the left of the = is tested to see if it is the same as the age on the right of the =.

3. An implicitly unwrapped optional gives permission for the optional to be unwrapped automatically whenever it is used.

A) True
B) False

4. What does declaring a variable with an optional type allow?

A) Changing the type of the variable after it is declared.
B) Getting the memory address of the variable.
C) Saving the variable's value to storage.
D) Setting the variable to no value.

5. Given the following Swift function:

func find(pattern: String, in info: String) -> Int? {
// code
}

What name is used to access the second parameter's value from within the function?

A) pattern
B) in
C) info
D) String

Explanation / Answer

1. True

2. A) If age on the right of the = is not nil, then the age on the left of the = is the unwrapped value of age

3. True

4. D)

5. C)