Page MenuHomeDevCentral

BaseCollection::first now returns an Option
ClosedPublic

Authored by dereckson on Nov 7 2025, 01:30.
Tags
None
Referenced Files
F20801595: D3852.diff
Mon, Jan 12, 04:23
Unknown Object (File)
Fri, Jan 9, 10:58
Unknown Object (File)
Thu, Jan 8, 08:53
Unknown Object (File)
Wed, Jan 7, 07:14
Unknown Object (File)
Wed, Jan 7, 03:37
Unknown Object (File)
Sun, Jan 4, 19:09
Unknown Object (File)
Sun, Jan 4, 07:42
Unknown Object (File)
Fri, Jan 2, 10:57
Subscribers
None

Details

Summary

Previous behavior: return first item or throw an option on empty collection
Current behavior: similar to Rust, return Some(first item) or None

The behavior of BaseCollection::firstOr is not changed, with eager loading.
For lazy loading, we can now use $collection->first()->getValueOrElse().

Test Plan
  • Unit tests have been updated
  • No-op for Zed code (it uses firstOr)

Diff Detail

Repository
rKERUALD Keruald libraries development repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable