Skip to content

Conversation

simPod
Copy link
Contributor

@simPod simPod commented Feb 22, 2021

  • we can have fully typed IterableObject now
  • asArray() can be easily supplemented with iterable_to_array()

@codecov
Copy link

codecov bot commented Feb 22, 2021

Codecov Report

Merging #32 (aed938b) into 2.0.x-dev (d0e80ba) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           2.0.x-dev       #32   +/-   ##
===========================================
  Coverage     100.00%   100.00%           
===========================================
  Files              3         3           
  Lines             39        37    -2     
===========================================
- Hits              39        37    -2     
Impacted Files Coverage Δ
src/IterableObject.php 100.00% <ø> (ø)
src/iterable-functions.php 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d0e80ba...aed938b. Read the comment docs.

- we can have fully typed IterableObject now
- asArray() can be easily supplemented with iterable_to_array()
@bpolaszek
Copy link
Owner

Hello @simPod,

Sorry but I'm against this one. It provides a convenient method to dump the results into an array when using the iterable fluent interface.

$iterable = // whatever array or traversable

$result = iterable($iterable)->filter()->map($mapFn)->asArray();

// Could also be written as iterable_to_array(iterable_map(iterable_filter($iterable), $mapFn)) 
// but reading is inverted, that's what the fluent interface solves.

@simPod
Copy link
Contributor Author

simPod commented Feb 22, 2021

If you're not convenient with it, just scratch it.

Though I see asArray() as something different compared to map and filter.

Map and filter transform data while still allowing us to work with iterable type.

asArray() changes the type and also is impossible to chain further. That's also the reason why it's impossible to type. So it's kind of a different thing and to me seems equivalent to calling iterable_to_array() Neither is fluent anyway 🤷🏾‍♀️ .

@bpolaszek
Copy link
Owner

Yes, that's the goal: do something with an iterable before exporting it as an array. I'm attached to that one 🙂

@bpolaszek bpolaszek closed this Feb 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants