InterviewSolution
Saved Bookmarks
| 1. |
What do you understand about optionals in ios Swift? What is the problem which they solve? |
|
Answer» An optional, in ios Swift, allows any type of variable to reflect a lack of value. The absence of value in Objective C is only available in reference types that use the nil special value. This is not possible with value types like int or float. With optionals, ios Swift EXTENDS the absence of value ideas to both reference and value types. An optional variable can be set to either a value or nil, which indicates that it has no value. An EXAMPLE of an optional is GIVEN below: var text: String?text = "I will GO to school."print(text) |
|