Skip to content

for inout loop #83

@oscbyspro

Description

@oscbyspro

There's a pitch related to Swift's ownership model for mutating iterated collection's elements in-place. I do it a lot in this package, so I'm looking forward to it. The gist of it is replacing the first with the second example:

var index = words.startIndex
while index < words.endIndex {
    mutate(&words[index])
    words.formIndex(after: &index)
}
for inout word in words {
    mutate(&word)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    awaitcan't be done yetbrrrsuch code, much wow

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions