Top "Optional" questions

An immutable type that may contain a value or reference.

Functional style of Java 8's Optional.ifPresent and if-not-Present?

In Java 8, I want to do something to an Optional object if it is present, and do another thing if …

java functional-programming java-8 optional
Proper usage of Optional.ifPresent()

I am trying to understand the ifPresent() method of the Optional API in Java 8. I have simple logic: Optional<…

java lambda java-8 optional
Swift: Testing optionals for nil

I'm using Xcode 6 Beta 4. I have this weird situation where I cannot figure out how to appropriately test for optionals. …

ios swift optional
Why should Java 8's Optional not be used in arguments

I've read on many Web sites Optional should be used as a return type only, and not used in method …

java java-8 optional
Are parameters in strings.xml possible?

In my Android app I'am going to implement my strings with internationalization. I have a problem with the grammar and …

android dynamic parameters string optional
What does an exclamation mark mean in the Swift language?

The Swift Programming Language guide has the following example: class Person { let name: String init(name: String) { self.name = name } …

swift optional forced-unwrapping
What is an optional value in Swift?

From Apple's documentation: You can use if and let together to work with values that might be missing. These values …

swift optional
How to execute logic on Optional if not present?

I want to replace the following code using java8 Optional: public Obj getObjectFromDB() { Obj obj = dao.find(); if (obj != null) { …

java java-8 optional
Difference between `Optional.orElse()` and `Optional.orElseGet()`

I am trying to understand the difference between the Optional<T>.orElse() and Optional<T>.orElseGet() …

java java-8 optional
Why use Optional.of over Optional.ofNullable?

When using the Java 8 Optional class, there are two ways in which a value can be wrapped in an optional. …

java java-8 nullpointerexception null optional