๐Ÿ”ธpublic property

Swift โŸฉ type โŸฉ property โŸฉ public property

'public' modifier is redundant for propertyโ•ฑstatic propertyโ•ฑinstance methodโ•ฑinitializerโ•ฑoperator declared in a public extension.

// public extension
public extension Vector2D {

    // static property
    public static var zero: Self {          // <--- โญ๏ธ `public`: redundantโ—๏ธ
        return Self.init(x: 0, y: 0)
    }
    
    // initializer
    public init(_ x: Scalar, _ y: Scalar) {  // <--- โญ๏ธ `public`: redundantโ—๏ธ
        self.init(x: x, y: y)
    }
    
    // property
    public var normSquared: Scalar {         // <--- โญ๏ธ `public`: redundantโ—๏ธ
        x * x + y * y
    }
    
    // operator function
    public static func + (u: Self, v: Self) -> Self { // <--- โญ๏ธ `public`: redundantโ—๏ธ
        return Self.init(x: u.x + v.x, y: u.y + v.y)
    }
    
    // instance method
    public func dot(_ v: Self) -> Scalar {   // <--- โญ๏ธ `public`: redundantโ—๏ธ
        return x * v.x + y * v.y
    }
}

Last updated