SwiftSemantics Documentation Beta

Structure Function.​Parameter

public struct Parameter: Hashable, Codable

A function parameter.

This type can also be used to represent initializer parameters and associated values for enumeration cases.

%3 Function.Parameter Function.Parameter Hashable Hashable Function.Parameter->Hashable ExpressibleBySyntax ExpressibleBySyntax Function.Parameter->ExpressibleBySyntax Codable Codable Function.Parameter->Codable CustomStringConvertible CustomStringConvertible Function.Parameter->CustomStringConvertible

Member Of

Function

A function declaration.

Conforms To

ExpressibleBySyntax

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

Codable
CustomStringConvertible
Hashable

Initializers

init(_:​)

public init(_ node: FunctionParameterSyntax)

Creates an instance initialized with the given syntax node.

Properties

attributes

let attributes: [Attribute]

The declaration attributes.

first​Name

let firstName: String?

The first, external name of the parameter.

For example, given the following function declaration, the first parameter has a firstName equal to nil, and the second parameter has a firstName equal to "by":

func increment(_ number: Int, by amount: Int = 1)

second​Name

let secondName: String?

The second, internal name of the parameter.

For example, given the following function declaration, the first parameter has a secondName equal to "number", and the second parameter has a secondName equal to "amount":

func increment(_ number: Int, by amount: Int = 1)

type

let type: String?

The type identified by the parameter.

For example, given the following function declaration, the first parameter has a type equal to "Person", and the second parameter has a type equal to "String":

func greet(_ person: Person, with phrases: String...)

variadic

let variadic: Bool

Whether the parameter accepts a variadic argument.

For example, given the following function declaration, the second parameter is variadic:

func greet(_ person: Person, with phrases: String...)

default​Argument

let defaultArgument: String?

The default argument of the parameter.

For example, given the following function declaration, the second parameter has a default argument equal to "1".

func increment(_ number: Int, by amount: Int = 1)

description

var description: String