Skip to content

Files

Latest commit

 

History

History
97 lines (70 loc) · 1.52 KB

multiline_literal_brackets.md

File metadata and controls

97 lines (70 loc) · 1.52 KB

Pattern: Malformed brackets for multi-line literal

Issue: -

Description

Multi-line literals should have their surrounding brackets in a new line.

Examples of correct code:

let trio = ["harry", "ronald", "hermione"]
let houseCup = ["gryffinder": 460, "hufflepuff": 370, "ravenclaw": 410, "slytherin": 450]


let trio = [
    "harry",
    "ronald",
    "hermione"
]
let houseCup = [
    "gryffinder": 460,
    "hufflepuff": 370,
    "ravenclaw": 410,
    "slytherin": 450
]


let trio = [
    "harry", "ronald", "hermione"
]
let houseCup = [
    "gryffinder": 460, "hufflepuff": 370,
    "ravenclaw": 410, "slytherin": 450
]


    _ = [
        1,
        2,
        3,
        4,
        5, 6,
        7, 8, 9
    ]

Examples of incorrect code:

let trio = ["harry",
            "ronald",
            "hermione"
]


let houseCup = ["gryffinder": 460, "hufflepuff": 370,
                "ravenclaw": 410, "slytherin": 450
]


let trio = [
    "harry",
    "ronald",
    "hermione"]


let houseCup = [
    "gryffinder": 460, "hufflepuff": 370,
    "ravenclaw": 410, "slytherin": 450]


class Hogwarts {
    let houseCup = [
        "gryffinder": 460, "hufflepuff": 370,
        "ravenclaw": 410, "slytherin": 450]
}


    _ = [
        1,
        2,
        3,
        4,
        5, 6,
        7, 8, 9]


    _ = [1, 2, 3,
         4, 5, 6,
         7, 8, 9
    ]

Further Reading