Parameter

public struct Parameter : Hashable, Codable
extension Function.Parameter: ExpressibleBySyntax
extension Function.Parameter: CustomStringConvertible

A function parameter.

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

  • The declaration attributes.

    Declaration

    Swift

    public let attributes: [Attribute]
  • 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)
    

    Declaration

    Swift

    public let firstName: 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)
    

    Declaration

    Swift

    public let secondName: 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...)
    

    Declaration

    Swift

    public let type: String?
  • 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...)
    

    Declaration

    Swift

    public let variadic: Bool
  • 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)
    

    Declaration

    Swift

    public let defaultArgument: String?

ExpressibleBySyntax

  • Creates an instance initialized with the given syntax node.

    Declaration

    Swift

    public init(_ node: FunctionParameterSyntax)

CustomStringConvertible

  • Declaration

    Swift

    public var description: String { get }