Swift Interview Questions and Answers

Question 4. What is a tuple?

Answer 4. Tuples group multiple values into a single compound value. The values within a tuple can be of any type and don’t have to be of the same type as each other. Tuples are particularly useful when returning multiple values from a function is more relevant.

Question 5. How do tuple differ from Array?

Answer 5. Tuple values cannot be iterated over and there is no way to know the number of elements or count of tuple.

Question 6 . What are optional in swift?

Answer 6. Optional in swift represent the possibility that a value may be absent. Represented by “?”. Optional represent two possibilities either there is a value or there is no value and a unwrapping of optional value must be done after testing it for the value.

var name:String?

if let a = name {
   array.append(a!)  // append the value of a in our array is its unwrapped safely
}

NEED A JOB? NEED TO HIRE? NEED HELP?

Join group of Software Professionals

iOS DEVELOPER’S DEN