Structure
Initializer
public struct Initializer: Declaration, Hashable, Codable
An initializer declaration.
Relationships
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: InitializerDeclSyntax)
Creates an instance initialized with the given syntax node.
Properties
keyword
let keyword: String
The declaration keyword ("associatedtype"
).
optional
let optional: Bool
Whether the initializer is optional.
genericParameters
let genericParameters: [GenericParameter]
The generic parameters for the declaration.
For example,
the following initializer declaration
has a single generic parameter
whose name
is "T"
and type
is "Equatable"
:
init<T: Equatable>(value: T) {}
throwsOrRethrowsKeyword
let throwsOrRethrowsKeyword: String?
The throws
or rethrows
keyword, if any.
genericRequirements
let genericRequirements: [GenericRequirement]
The generic parameter requirements for the declaration.
For example,
the following initializer declaration
has a single requirement
that its generic parameter identified as "T"
conforms to the type identified as "Hahable"
:
init<T>(value: T) where T: Hashable {}
description
var description: String