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

dropRightWhile #12

Open
elizabethsiegle opened this issue Oct 8, 2019 · 2 comments
Open

dropRightWhile #12

elizabethsiegle opened this issue Oct 8, 2019 · 2 comments

Comments

@elizabethsiegle
Copy link
Owner

Make a function that removes elements from the end of an array until the passed function returns true and returns the remaining elements in the array.

@abdulajet
Copy link
Contributor

I got this :)

@abdulajet
Copy link
Contributor

I am not sure thing can be made generic without it being an extension on Collection. Otherwise the call site sorta will have to look like this:

drop(arr: [1, 2, 3, 4, 5]) { element in
    guard let element = element as? Int else { return false }
    return element > 3
}

vs doing something cool like:

drop(arr: [1, 2, 3, 4, 5], while: {$0 > 3}) 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants