dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.28k stars 1.58k forks source link

`Iterable.any` docs slightly unclear? #59576

Open ditman opened 1 day ago

ditman commented 1 day ago

I was reading the docs for Iterable.any and it says this:

Checks every element in iteration order, and returns true if any of them make test return true, otherwise returns false. Returns false if the iterable is empty.

At first I thought that it'd check every (all) element in iteration order, then return true if any of them makes test return true.

But the implementation actually returns immediately:

I think something like this may be clearer:

"Checks elements in iteration order, and returns true when any of them makes test return true, otherwise returns false."

(This maybe too subtle a change for my level of english, though 😅)

dart-github-bot commented 1 day ago

Summary: User finds Iterable.any documentation unclear. The current wording implies a complete iteration before returning, while it short-circuits.

lrhn commented 1 day ago

Old docs are often quite terse. Makes sense to write something more here.