Subscript
public struct Subscript : Declaration, Hashable, Codable
extension Subscript: ExpressibleBySyntax
extension Subscript: CustomStringConvertible
A subscript declaration.
-
A dot-delimited (
.
) path used to qualify the function name within the module scope of the declaration, ornil
if the function isn’t nested (that is, declared at the top-level scope of a module).For example, given the following declaration of a subscript, the
context
is"A.B"
:enum A { struct B { subscript(index: Int) -> Int? { ... } } }
Declaration
Swift
public let context: String?
-
The declaration attributes.
Declaration
Swift
public let attributes: [Attribute]
-
The declaration modifiers.
Declaration
Swift
public let modifiers: [Modifier]
-
The declaration keyword (
"subscript"
).Declaration
Swift
public let keyword: String
-
The subscript indices.
Declaration
Swift
public let indices: [Function.Parameter]
-
The generic parameters for the declaration.
For example, the following subscript declaration has a single generic parameter whose
name
is"T"
andtype
is"Equatable"
:subscript<T: Equatable>(value: T) {}
Declaration
Swift
public let genericParameters: [GenericParameter]
-
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 {}
Declaration
Swift
public let genericRequirements: [GenericRequirement]
-
The return type of the subscript.
Declaration
Swift
public let returnType: String
-
The subscript getter and/or setter.
Declaration
Swift
public let accessors: [Variable.Accessor]
-
Creates an instance initialized with the given syntax node.
Declaration
Swift
public init(_ node: SubscriptDeclSyntax)
-
Declaration
Swift
public var description: String { get }