class Myst::Param

Overview

A parameter for a method definition. Parameters can take many forms. The simplest parameter is just a name or a pattern. If the parameter is a name, it may be prefixed by a '*' to indicate a splat argument, or a '&' to indicate a block argument.

Additionally, if the parameter is a name, it may be prefixed with a pattern and a match operator, or suffixed with a type restriction and/or guard clause, as shown in the final form.

pattern | '*' name | '&' name | [ pattern '=:' ] name [ ':' const ] [ '|' guard ]

Defined in:

myst/syntax/ast.cr

Constructors

Instance Method Summary

Instance methods inherited from class Myst::Node

accept(visitor) accept, accept_children(visitor) accept_children, at(node : Node)
at(node : Nil)
at(location : Location)
at
, at_end(node : Node)
at_end(node : Nil)
at_end(end_location : Location)
at_end
, class_desc : String class_desc, end_location : Location | Nil end_location, end_location=(end_location : Location | Nil) end_location=, location : Location | Nil location, location=(location : Location | Nil) location=

Constructor Detail

def self.new(pattern : Myst::Node | Nil = nil, name : Nil | String = nil, restriction : Nil | Myst::Const = nil, guard : Myst::Node | Nil = nil, splat : Bool = false, block : Bool = false) #

[View source]

Instance Method Detail

def ==(other : self) #
Description copied from class Reference

Returns true if this reference is the same as other. Invokes same?.


def accept_children(visitor) #

[View source]
def block=(block : Bool) #

[View source]
def block? : Bool #

[View source]
def guard : Node | Nil #

def guard=(guard : Node | Nil) #

[View source]
def guard? : Node | Nil | Nil #

def hash(hasher) #
Description copied from class Reference

See Object#hash(hasher)


def name : String | Nil #

def name=(name : String | Nil) #

[View source]
def name? : String | Nil | Nil #

def pattern : Node | Nil #

def pattern=(pattern : Node | Nil) #

[View source]
def pattern? : Node | Nil | Nil #

def restriction : Const | Nil #

def restriction=(restriction : Const | Nil) #

[View source]
def restriction? : Const | Nil | Nil #

def splat=(splat : Bool) #

[View source]
def splat? : Bool #

[View source]