Skip to content

component1 for Optional? #19

@AlecKazakova

Description

@AlecKazakova

Often times in code i do something like:

optionalStream()
  .subscribe { fooOptional ->
    val foo = fooOptional.toNullable()
    if (foo != null) ...
    else ...
  }

with operator fun component1() = toNullable() implemented on Optional I could instead do:

optionalStream()
  .subscribe { (foo) ->
    if (foo != null) ...
    else ...
  }

tiny optimization. Happy to contribute this if it makes sense but since its api changing I figured I'd issue first in case it doesnt make sense

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions