Skip to content

Files

Latest commit

 

History

History
67 lines (42 loc) · 852 Bytes

empty_enum_arguments.md

File metadata and controls

67 lines (42 loc) · 852 Bytes

Pattern: Redundant enum argument

Issue: -

Description

Arguments can be omitted when matching enums with associated types if they are not used.

Examples of correct code:

switch foo {
    case .bar: break
}


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


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


switch (foo, bar) {
    case (_, _): break
}


switch foo {
    case "bar".uppercased(): break
}


switch (foo, bar) {
    case (_, _) where !something: break
}

Examples of incorrect code:

switch foo {
    case .bar(_): break
}


switch foo {
    case .bar(): break
}


switch foo {
    case .bar(_), .bar2(_): break
}


switch foo {
    case .bar() where method() > 2: break
}

Further Reading