[swift-evolution] [Review] SE-0032: Add find method to SequenceType
Jose Cheyo Jimenez
cheyo at masters3d.com
Thu Apr 28 23:43:27 CDT 2016
> * What is your evaluation of the proposal?
I think it is too limiting and I’d rather have find() be merged with current index() method.
// I believe these used to be called find() in swift 1.0
func index(of element: Self.Iterator.Element) -> Self.Index?
func index(@noescape where predicate: (Self.Iterator.Element) throws -> Bool) rethrows -> Self.Index?
I think it is really confusing to have an index() and a find() that do very similar things.
I rather have an overloaded find()
func find(indexOf element: Self.Iterator.Element) -> Self.Index?
func find(@noescape indexOf predicate: (Self.Iterator.Element) throws -> Bool) rethrows -> Self.Index?
func find(@noescape element predicate: (Self.Iterator.Element) throws -> Bool) rethrows -> Self.Iterator.Element?
// Return a tuple with the index and element
func find(@noescape predicate: (Self.Iterator.Element) throws -> Bool) rethrows -> (index:Self.Index, element:Self.Iterator.Element)?
> * Is the problem being addressed significant enough to warrant a change to Swift?
yes, I use filter for this but I believe find() and index() should be merged for it to be worth it.
> * Does this proposal fit well with the feel and direction of Swift?
yes but I believe index() should be renamed to find()
> * If you have you used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?
python.
> * How much effort did you put into your review? A glance, a quick reading, or an in-depth study?
read the proposal and suggested an extension of scope.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160428/c7cacef6/attachment.html>
More information about the swift-evolution
mailing list