<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body><div>Hey guys,<br></div>
<div><br></div>
<div>I would like to pitch a small convenient change to the Swift stdlib. With KeyPaths added in&nbsp;SE-0161 I would like to add some convenience calls to map, flatMap and filter in Sequences. To extract properties of an array of objects we currently use trailing closure syntax together with the shorthand $0 for the first closure argument. This is still kind of verbose and also hard to read in some situations.<br></div>
<div>I think it is much better to understand what is going on when using the type safe KeyPaths for that. I already implemented a working solution and would like to pitch the idea here to get some feedback before opening the swift evolution proposal.<br></div>
<div>I propose using&nbsp;<br></div>
<div><br></div>
<div>persons.flatMap(keyPath: \.name)<br></div>
<div><br></div>
<div>over<br></div>
<div><br></div>
<div>persons.flatMap { $0.name }<br></div>
<div><br></div>
<div>Link to pull request:&nbsp;<a href="https://github.com/apple/swift/pull/10760">https://github.com/apple/swift/pull/10760</a><br></div>
<div><br></div>
<div>Link to proposal draft:&nbsp;<a href="https://github.com/BenchR267/swift-evolution/blob/keypath-based-map/proposals/0181-keypath-based-map-flatmap-filter.md">https://github.com/BenchR267/swift-evolution/blob/keypath-based-map/proposals/0181-keypath-based-map-flatmap-filter.md</a><br></div>
<div><br></div>
<div>Thanks in advance for your feedback!<br></div>
<div id="sig64302232"><div class="signature">______________________<br></div>
<div class="signature"><br></div>
<div class="signature">Benjamin Herzog<br></div>
</div>
<div><br></div>
</body>
</html>