Closed fritz-c closed 6 days ago
The existing code comment was copied from when, and therefore mistakenly explains the callback is called when the value is truthy.
when
And just for reference, here was my own sanity check, done in tinker:
> collect([1,2,3,4])->unless(false,fn($a)=>$a->prepend(62362)) = Illuminate\Support\Collection {#7422 all: [ 62362, 1, 2, 3, 4, ], } > collect([1,2,3,4])->unless(true,fn($a)=>$a->prepend(62362)) = Illuminate\Support\Collection {#7351 all: [ 1, 2, 3, 4, ], }
The existing code comment was copied from
when
, and therefore mistakenly explains the callback is called when the value is truthy.And just for reference, here was my own sanity check, done in tinker: