Skip to content

Files

Latest commit

 

History

History
102 lines (63 loc) · 1.22 KB

pattern_matching_keywords.md

File metadata and controls

102 lines (63 loc) · 1.22 KB

Pattern: Unmerged pattern matching bindings

Issue: -

Description

Combine multiple pattern matching bindings by moving keywords out of tuples.

Examples of correct code:

switch foo {
    default: break
}


switch foo {
    case 1: break
}


switch foo {
    case bar: break
}


switch foo {
    case let (x, y): break
}


switch foo {
    case .foo(let x): break
}


switch foo {
    case let .foo(x, y): break
}


switch foo {
    case .foo(let x), .bar(let x): break
}


switch foo {
    case .foo(let x, var y): break
}


switch foo {
    case var (x, y): break
}


switch foo {
    case .foo(var x): break
}


switch foo {
    case var .foo(x, y): break
}

Examples of incorrect code:

switch foo {
    case (let x,  let y): break
}


switch foo {
    case .foo(let x, let y): break
}


switch foo {
    case (.yamlParsing(let x), .yamlParsing(let y)): break
}


switch foo {
    case (var x,  var y): break
}


switch foo {
    case .foo(var x, var y): break
}


switch foo {
    case (.yamlParsing(var x), .yamlParsing(var y)): break
}

Further Reading