Skip to content

Conversation

@adamkiss
Copy link
Contributor

@adamkiss adamkiss commented Feb 2, 2023

This PR …

Sometimes, when doing parametric stuff, it's nice to create an array with some default values - which are not the same.

Small change to A::fill makes it accept a closure/callable, so it can be used to create new arrays with useful values:

$new = A::fill([], 10, fn($i) => $i); // [0, 1, 2, 3, …]
$new2 = A::fill($new, 15, fn($i) => $i); // correctly adds [10, 11, …]

Ready?

  • Unit tests for fixed bug/feature
  • In-code documentation (wherever needed)
  • Tests and checks all pass

For review team

@adamkiss
Copy link
Contributor Author

adamkiss commented Feb 2, 2023

Current error is something with CI, not in my code AFAICT

@afbora afbora changed the base branch from main to develop February 2, 2023 23:38
@distantnative
Copy link
Member

I think we can make this a bit cleaner by letting the loop start at the array count and go up to the limit

@distantnative distantnative merged commit 1bf3e32 into getkirby:develop Feb 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants