Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a version of interspersed that accepts a closure. #160

Open
kennycarruthers opened this issue Aug 6, 2021 · 0 comments
Open

Provide a version of interspersed that accepts a closure. #160

kennycarruthers opened this issue Aug 6, 2021 · 0 comments

Comments

@kennycarruthers
Copy link

When doing macOS or iOS programming, a common use-case I have for interspersed is to insert a separator or divider view in-between a bunch of other views.

Example, given an array of views, I'd like to insert a separator view in-between each one:

let views = [view1, view2, view3]

let allViews = views.interspersed(using: { SeparatorView() })

Expected:

[view1, separator1, view2, separator2, view3]

Because these are NSView, the inserted element needs to be a new instance each time, which the existing implementation does not appear to offer.

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

No branches or pull requests

1 participant