SwiftSemantics Documentation Beta

Structure Subscript

public struct Subscript: Declaration, Hashable, Codable

A subscript declaration.

%3 Subscript Subscript Declaration Declaration Subscript->Declaration Codable Codable Subscript->Codable CustomStringConvertible CustomStringConvertible Subscript->CustomStringConvertible ExpressibleBySyntax ExpressibleBySyntax Subscript->ExpressibleBySyntax Hashable Hashable Subscript->Hashable

Conforms To

Declaration

A Swift declaration.

ExpressibleBySyntax

A type that can be initialized with a Swift syntax node.

Codable
CustomStringConvertible
Hashable

Initializers

init(_:​)

public init(_ node: SubscriptDeclSyntax)

Creates an instance initialized with the given syntax node.

Properties

attributes

let attributes: [Attribute]

The declaration attributes.

modifiers

let modifiers: [Modifier]

The declaration modifiers.

keyword

let keyword: String

The declaration keyword ("subscript").

indices

let indices: [Function.Parameter]

The subscript indices.

generic​Parameters

let genericParameters: [GenericParameter]

The generic parameters for the declaration.

For example, the following subscript declaration has a single generic parameter whose name is "T" and type is "Equatable":

subscript<T: Equatable>(value: T) {}

generic​Requirements

let genericRequirements: [GenericRequirement]

The generic parameter requirements for the declaration.

For example, the following subscript declaration has a single requirement that its generic parameter identified as "T" conforms to the type identified as "Hahable":

subscript<T>(value: T) where T: Hashable {}

return​Type

let returnType: String

The return type of the subscript.

accessors

let accessors: [Variable.Accessor]

The subscript getter and/or setter.

description

var description: String