Top "Optional" questions

An immutable type that may contain a value or reference.

Downcasting optionals in Swift: as? Type, or as! Type?

Given the following in Swift: var optionalString: String? let dict = NSDictionary() What is the practical difference between the following two …

swift optional downcast optional-variables
How to solve "String interpolation produces a debug description for an optional value; did you mean to make this explicit?" in Xcode 8.3 beta?

Since beta 8.3, zillions warnings "String interpolation produces a debug description for an optional value; did you mean to make this …

swift swift3 optional string-interpolation
Type Has No Subscript Members?

I get the error "Type 'Ship' has no subscript members when I try to do: var coor = ship[index] I …

ios swift optional nscoding subscript
Optional return in C#.Net

Java 1.8 is receiving the Optional<T> class, that allows us to explicitly say when a method may return …

c# .net nullable optional
Statement lambda can be replaced with expression lambda

I do user and invitation validation using the Optional facility @DeleteMapping("/friends/{username}") public HttpEntity<Boolean> removeFriend( @ApiParam(…

java spring spring-mvc lambda optional
Monads with Java 8

In the interests of helping to understand what a monad is, can someone provide an example using java ? Are they …

java java-8 monads optional
Swift: testing against optional value in switch case

In Swift, how can I write a case in a switch statement that tests the value being switched against the …

swift enums switch-statement optional
Why java.util.Optional is not Serializable, how to serialize the object with such fields

The Enum class is Serializable so there is no problem to serialize object with enums. The other case is where …

java serialization java-8 optional
find whether an element exists by a particular tag name in XML

I have an XML file where some sub tags (child node elements) are optional. e.g. <part> <…

java xml optional tagname
Getopt optional arguments?

I have a program where you enter an option -d and then whether or not you supply a non-optional argument …

c arguments option getopt optional