iOS

Swift Basics

Variables & constants, types, optionals, closures, control flow, error handling

25 preguntas de entrevista·
Junior
1

What is the difference between 'let' and 'var' in Swift?

Respuesta

let declares an immutable constant while var declares a mutable variable. A constant cannot be changed after declaration, but a variable can change value. Use let by default for safety and code clarity.

2

Which data type is used to represent true or false in Swift?

Respuesta

The Bool type is used for boolean values true and false. It is a fundamental type in Swift used in conditionals to control execution flow. Other types serve different purposes: Int for integers, String for text, Boolean does not exist in Swift.

3

What is type inference in Swift?

Respuesta

Type inference allows Swift to automatically deduce a variable's type from its initial value. For example, if you assign 42, Swift infers Int. If you assign text, Swift infers String. This makes code concise without losing type safety. You can annotate explicitly if needed.

4

What is an optional in Swift?

5

How do you safely unwrap an optional using 'if let'?

+22 preguntas de entrevista

Domina iOS para tu próxima entrevista

Accede a todas las preguntas, flashcards, tests técnicos, ejercicios de code review y simuladores de entrevista.

Empieza gratis