[swift-evolution] SE-0105: Removing Where Clauses from For-In Loops

Erica Sadun erica at ericasadun.com
Fri Jun 24 16:33:39 CDT 2016


> On Jun 24, 2016, at 12:04 AM, Xiaodi Wu <xiaodi.wu at gmail.com> wrote:
> 
> On Fri, Jun 24, 2016 at 12:59 AM, William Shipley via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
> Here are some of my real-world examples:
> 
>         for modelUUIDAndInterfaceElement in modelUUIDsToInterfaceElements where !usedInterfaceElements.contains(modelUUIDAndInterfaceElement.1) {
> 
> Not a practitioner of 80-character line limits, I take it?

80-character line limits aren't why these examples  are problematic for me.
Other than a few positive examples like this wall.anchors one, 

>          for anchor in wall.anchors where boundsRect.contains(anchor.origin) {

most of these read as if there is too much logic stuffed into a single line:

> for otherWall: Wall in self where otherWall != wall && !removedWalls.contains(otherWall) {
> 
>         for otherPieceOfFurnitureNode in localFurnitureModelUUIDsToInterfaceElements!.values where otherPieceOfFurnitureNode !== pieceOfFurnitureNode {
> 
>         for lineSegmentObject in wallRelatedLineSegments where remainingLineSegments.contains(lineSegmentObject) {
> 
>         for colinearLineSegmentObject in remainingLineSegments where colinearLineSegmentObject.angle.isEssentially(infiniteLineAngle: lineSegmentObject.angle) {
>
-- E


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160624/3fd52853/attachment.html>


More information about the swift-evolution mailing list