SwiftSemantics Documentation Beta

Structure Initializer

public struct Initializer: Declaration, Hashable, Codable

An initializer declaration.

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

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

attributes

let attributes: [Attribute]

The declaration attributes.

modifiers

let modifiers: [Modifier]

The declaration modifiers.

keyword

let keyword: String

The declaration keyword ("associatedtype").

optional

let optional: Bool

Whether the initializer is optional.

generic​Parameters

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) {}

parameters

let parameters: [Function.Parameter]

The initializer inputs.

throws​OrRethrows​Keyword

let throwsOrRethrowsKeyword: String?

The throws or rethrows keyword, if any.

generic​Requirements

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