Top "Optional" questions

An immutable type that may contain a value or reference.

Swift: guard let vs if let

I have been reading about Optionals in Swift, and I have seen examples where if let is used to check …

swift swift2 optional conventions control-flow
Mockito error with method that returns Optional<T>

I have an interface with the following method public interface IRemoteStore { <T> Optional<T> get(String …

java mockito optional
Regex optional capturing group?

After hours of searching I decided to ask this question. Why doesn't this regular expression ^(dog).+?(cat)? work as I …

regex optional capturing-group
In Java 8, transform Optional<String> of an empty String in Optional.empty

Given a String I need to get an Optional, whereby if the String is null or empty the result would …

java java-8 optional
Assert that Optional has certain value

I have a Java method that returns an Optional. I'd like to write an easy-to-read unit test for it that …

java unit-testing optional
How to remove all gesture recognizers from a UIView in Swift

I have written Swift code that attempts to remove all gesture recognizers from all subviews of a given custom UIView …

ios uiview swift uigesturerecognizer optional
Chaining Optionals in Java 8

Looking for a way to chain optionals so that the first one that is present is returned. If none are …

java lambda java-8 optional
Required and Optional Arguments Using Boost Library Program Options

I'm using Boost Program Options Library to parse the command line arguments. I have the following requirements: Once "help" is …

c++ boost boost-program-options required optional
When should I compare an optional value to nil?

Quite often, you need to write code such as the following: if someOptional != nil { // do something with the unwrapped someOptional …

ios swift optional swift2
Expression implicitly coerced from 'String?' to Any

I have some error like this "Expression implicitly coerced from String? to Any" this is my code : func application(_ application: …

swift string optional