Skip to content
This repository has been archived by the owner on Oct 17, 2021. It is now read-only.

Attribute

mattt edited this page Mar 28, 2020 · 7 revisions

Attribute

A declaration attribute.

public struct Attribute: Hashable, Codable

Attributes provide additional information about a declaration. For example, the @discardableResult attribute indicates that a function may be called without using the result.

Inheritance

Codable, Hashable

Nested Types

Attribute.Argument

Initializers

init(_:)

Creates an instance initialized with the given syntax node.

public init(_ node: AttributeSyntax)

Properties

name

The attribute name.

let name: String

An attribute's name is everything after the at-sign (@) and before the argument clause. For example, the name of the attribute in the following declaration is "available":

@available(macOS 10.15, iOS 13, *)

description

var description: String

description

var description: String

arguments

The attribute's arguments, if any.

let arguments: [Argument]