Top "Optional" questions

An immutable type that may contain a value or reference.

unwrapping multiple optionals in if statement

I want to unwrap two optionals in one if statement, but the compiler complaints about an expected expression after operator …

swift optional
How to add nil value to Swift Dictionary?

I have made a request to my server in my app. And posted data something like this.Server side is …

swift dictionary null optional
Usage of where in if let assignment in Swift

The Swift documentation at page 61 of the Swift manual hints to the possibility of using where to join an optional …

ios swift where optional swift3
Is it a good practice to use Optional as an attribute in a class?

I have read something about the purpose of Optional (unfortunately I don't remember where) in Java 8, and I was surprised …

java java-8 optional
Get value from one Optional or another

I have two java.util.Optional instances and I want to get an Optional that either: Has the value of …

java java-8 optional
PHPDoc optional parameter

There are already 2 similar questions of this type here on SO but none of the answers seem to work. PHPDoc …

php phpdoc param optional
Swift if statement - multiple conditions separated by commas?

Looking at a Swift example: if let sourceViewController = sender.sourceViewController as? MealViewController, meal = sourceViewController.meal { ... } The doc states: ... the code …

ios swift if-statement optional
Swift variable decorations with "?" (question mark) and "!" (exclamation mark)

I understand that in Swift all variables must be set with a value, and that by using optionals we can …

swift optional
optional array in avro schema

I'm wondering whether or not it is possible to have an optional array. Let's assume a schema like this: { "type": "…

arrays null optional avro
Optional.ofNullable and method chaining

I was surprised by Optional.ofNullable method. Some day I wrote a function that supposed to return an Optional: private …

java java-8 optional