# class Prism::ParametersNode

Represents the list of parameters on a method, block, or lambda definition.

    def a(b, c, d)
          ^^^^^^^
    end

### Attributes

block [R]

attr_reader block: `BlockParameterNode`?

keyword_rest [R]

attr_reader `keyword_rest`: `KeywordRestParameterNode` | `ForwardingParameterNode` | `NoKeywordsParameterNode` | nil

keywords [R]

attr_reader keywords: Array[RequiredKeywordParameterNode | OptionalKeywordParameterNode]

optionals [R]

attr_reader optionals: Array

posts [R]

attr_reader posts: Array[RequiredParameterNode | `MultiTargetNode` | `KeywordRestParameterNode` | `NoKeywordsParameterNode` | ForwardingParameterNode]

requireds [R]

attr_reader requireds: Array[RequiredParameterNode | MultiTargetNode]

rest [R]

attr_reader rest: `RestParameterNode` | `ImplicitRestNode` | nil

### Public Class Methods

new (source, node_id, location, flags, requireds, optionals, rest, posts, keywords, keyword_rest, block)
Source

    # File lib/prism/node.rb, line 14149
    def initialize(source, node_id, location, flags, requireds, optionals, rest, posts, keywords, keyword_rest, block)
      @source = source
      @node_id = node_id
      @location = location
      @flags = flags
      @requireds = requireds
      @optionals = optionals
      @rest = rest
      @posts = posts
      @keywords = keywords
      @keyword_rest = keyword_rest
      @block = block
    end

Initialize a new `ParametersNode` node.

type ()
Source

    # File lib/prism/node.rb, line 14236
    def self.type
      :parameters_node
    end

Return a symbol representation of this node type. See ‘Node::type`.

### Public Instance Methods

=== (other)
Source

    # File lib/prism/node.rb, line 14242
    def ===(other)
      other.is_a?(ParametersNode) &&
        (requireds.length == other.requireds.length) &&
        requireds.zip(other.requireds).all? { |left, right| left === right } &&
        (optionals.length == other.optionals.length) &&
        optionals.zip(other.optionals).all? { |left, right| left === right } &&
        (rest === other.rest) &&
        (posts.length == other.posts.length) &&
        posts.zip(other.posts).all? { |left, right| left === right } &&
        (keywords.length == other.keywords.length) &&
        keywords.zip(other.keywords).all? { |left, right| left === right } &&
        (keyword_rest === other.keyword_rest) &&
        (block === other.block)
    end

Implements case-equality for the node. This is effectively == but without comparing the value of locations. Locations are checked only for presence.

accept (visitor)
Source

    # File lib/prism/node.rb, line 14164
    def accept(visitor)
      visitor.visit_parameters_node(self)
    end

def accept: (`Visitor` visitor) -> void

child_nodes ()
Source

    # File lib/prism/node.rb, line 14169
    def child_nodes
      [*requireds, *optionals, rest, *posts, *keywords, keyword_rest, block]
    end

def `child_nodes`: () -> Array[nil | Node]

Also aliased as: deconstruct
comment_targets ()
Source

    # File lib/prism/node.rb, line 14187
    def comment_targets
      [*requireds, *optionals, *rest, *posts, *keywords, *keyword_rest, *block] #: Array[Prism::node | Location]
    end

def `comment_targets`: () -> Array[Node | Location]

compact_child_nodes ()
Source

    # File lib/prism/node.rb, line 14174
    def compact_child_nodes
      compact = [] #: Array[Prism::node]
      compact.concat(requireds)
      compact.concat(optionals)
      compact << rest if rest
      compact.concat(posts)
      compact.concat(keywords)
      compact << keyword_rest if keyword_rest
      compact << block if block
      compact
    end

def `compact_child_nodes`: () -> Array

copy (node_id: self.node_id, location: self.location, flags: self.flags, requireds: self.requireds, optionals: self.optionals, rest: self.rest, posts: self.posts, keywords: self.keywords, keyword_rest: self.keyword_rest, block: self.block)
Source

    # File lib/prism/node.rb, line 14192
    def copy(node_id: self.node_id, location: self.location, flags: self.flags, requireds: self.requireds, optionals: self.optionals, rest: self.rest, posts: self.posts, keywords: self.keywords, keyword_rest: self.keyword_rest, block: self.block)
      ParametersNode.new(source, node_id, location, flags, requireds, optionals, rest, posts, keywords, keyword_rest, block)
    end

def copy: (?node_id: `Integer`, ?location: `Location`, ?flags: `Integer`, ?requireds: Array[RequiredParameterNode | MultiTargetNode], ?optionals: Array, ?rest: `RestParameterNode` | `ImplicitRestNode` | nil, ?posts: Array[RequiredParameterNode | `MultiTargetNode` | `KeywordRestParameterNode` | `NoKeywordsParameterNode` | ForwardingParameterNode], ?keywords: Array[RequiredKeywordParameterNode | OptionalKeywordParameterNode], ?keyword_rest: `KeywordRestParameterNode` | `ForwardingParameterNode` | `NoKeywordsParameterNode` | nil, ?block: `BlockParameterNode`?) -> `ParametersNode`

deconstruct ()

def deconstruct: () -> Array[nil | Node]

Alias for: child_nodes
deconstruct_keys (keys)
Source

    # File lib/prism/node.rb, line 14200
    def deconstruct_keys(keys)
      { node_id: node_id, location: location, requireds: requireds, optionals: optionals, rest: rest, posts: posts, keywords: keywords, keyword_rest: keyword_rest, block: block }
    end

def `deconstruct_keys`: (Array keys) -> { node_id: `Integer`, location: `Location`, requireds: Array[RequiredParameterNode | MultiTargetNode], optionals: Array, rest: `RestParameterNode` | `ImplicitRestNode` | nil, posts: Array[RequiredParameterNode | `MultiTargetNode` | `KeywordRestParameterNode` | `NoKeywordsParameterNode` | ForwardingParameterNode], keywords: Array[RequiredKeywordParameterNode | OptionalKeywordParameterNode], `keyword_rest`: `KeywordRestParameterNode` | `ForwardingParameterNode` | `NoKeywordsParameterNode` | nil, block: `BlockParameterNode`? }

inspect ()
Source

    # File lib/prism/node.rb, line 14226
    def inspect
      InspectVisitor.compose(self)
    end

def inspect -> `String`

signature ()
Source

    # File lib/prism/node_ext.rb, line 269
    def signature
      names = [] #: Array[[Symbol, Symbol] | [Symbol]]

      requireds.each do |param|
        names << (param.is_a?(MultiTargetNode) ? [:req] : [:req, param.name])
      end

      optionals.each { |param| names << [:opt, param.name] }

      if rest && rest.is_a?(RestParameterNode)
        names << [:rest, rest.name || :*]
      end

      posts.each do |param|
        case param
        when MultiTargetNode
          names << [:req]
        when NoKeywordsParameterNode, KeywordRestParameterNode, ForwardingParameterNode
          # Invalid syntax, e.g. "def f(**nil, ...)" moves the NoKeywordsParameterNode to posts
          raise "Invalid syntax"
        else
          names << [:req, param.name]
        end
      end

      # Regardless of the order in which the keywords were defined, the required
      # keywords always come first followed by the optional keywords.
      keyopt = [] #: Array[OptionalKeywordParameterNode]
      keywords.each do |param|
        if param.is_a?(OptionalKeywordParameterNode)
          keyopt << param
        else
          names << [:keyreq, param.name]
        end
      end

      keyopt.each { |param| names << [:key, param.name] }

      case keyword_rest
      when ForwardingParameterNode
        names.concat([[:rest, :*], [:keyrest, :**], [:block, :&]])
      when KeywordRestParameterNode
        names << [:keyrest, keyword_rest.name || :**]
      when NoKeywordsParameterNode
        names << [:nokey]
      end

      names << [:block, block.name || :&] if block
      names
    end

Mirrors the `Method#parameters` method.

type ()
Source

    # File lib/prism/node.rb, line 14231
    def type
      :parameters_node
    end

Return a symbol representation of this node type. See ‘Node#type`.