question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`onEach` working for nullable iterables

See original GitHub issue

Currently, one cannot apply onEach validation if iterable field is nullable, for example val items: List<MyClass>? There should be some way to do it either by making it possible to combine ifPresent with onEach or by making onEach treat a null iterable in the same way as an empty iterable. There could also be new method like onEachIfPresent

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
matfiej88commented, Feb 23, 2022

+1 for nested option

1reaction
wtomicommented, Feb 23, 2022

I also like the nested option. It seems like a natural extension because onEach would work in the same way as it has been. I can try to implement it later.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dealing with parallel flux in Reactor - Stack Overflow
And on each iterable I have to make a rest call. ... It won't work immediately after flatMap because parallel() creates a ParallelFlux...
Read more >
Iterable - Kotlin Programming Language
Returns the first non-null value produced by transform function being applied to elements of this collection in iteration order, or null if no...
Read more >
IterableUtils (Apache Commons Collections 4.4 API)
Returns an immutable empty iterable if the argument is null, or the argument itself otherwise. static <E> Iterable<E>, emptyIterable(). Gets an empty iterable....
Read more >
Iterable (Groovy JDK enhancements)
Iterates through the Iterable calling the given closure condition for each item but stopping once the first non-null result is found and returning...
Read more >
Iterable class - dart:core library - Flutter - Dart API docs
Iterable <E> class Null safety. A collection of values, or "elements", that can be accessed sequentially. The elements of the iterable are accessed...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found