class

Myst::Def

Inherits Myst::Node / Reference / Object

A method definition. Parameters for methods must be wrapped in parentheses. If the method does not accept parameters, the parentheses may be omitted. In the context of a type definition, methods can also be defined as "static" - or related to the type, rather than instances of the type - using the alternate keyword defstatic.

For any definition, the return type can be specified as a type restriction on the method itself using the : Type syntax, similar to the parameters.

[ 'def' | 'defstatic' ] name '(' [ param [ ',' param ]* ] ')' [ ':' return_type ] body 'end' | [ 'def' | 'defstatic' ] name [ ':' return_type ] body 'end'

Constructors

new(name : String, params : Array(Myst::Param) = [] of Param, body : Myst::Node = Nop.new, *, return_type : Myst::Node | Nil = nil, block_param : Nil | Myst::Param = nil, splat_index : Int32 | Nil = nil, static : Bool = false)
Source

Instance methods

==(other : self)

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

accept_children(visitor)
Source
block_param
Source
block_param=(block_param : Param | Nil)
Source
block_param?
Source
body
Source
body=(body : Node)
Source
hash(hasher)

See Object#hash(hasher)

name
Source
name=(name : String)
Source
params
Source
params=(params : Array(Param))
Source
return_type
Source
return_type=(return_type : Node | Nil)
Source
return_type?
Source
splat_index
Source
splat_index=(splat_index : Int32 | Nil)
Source
splat_index?
Source
static=(static : Bool)
Source
static?
Source