Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Destructuring Option instances #897

@nhaarman

Description

@nhaarman

The Option class currently does not define a component1() function to be able to destructure it.

A common use case is wrapping a nullable type in an Option because RxJava does not allow null values in its streams:

.subscribe { myOption : Option<T> ->
  value = myOption.orNull()
}

Instead, when destructuring:

.subscribe { (myValue : T?) ->
  value = myValue
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions