class Myst::Block

Overview

A block definition. Functionally, a block is equivalent to a method definition. The only difference being that a block is always unnamed. Syntax-wise, blocks appear as the last expression in a Call, and can be created either by a do...end construct or curly braces ({ ... }).

'do' [ '|' param [ ',' param ]* '|' ] body 'end' | '{' [ '|' param [ ',' param ]* '|' ] body '}'

Convention recommends that the brace form only be used for single-line blocks, and the do...end form only be used for multi-line blocks.

Defined in:

myst/syntax/ast.cr

Constructors

Instance Method Summary

Instance methods inherited from class Myst::Def

==(other : self) ==, accept_children(visitor) accept_children, block_param : Param | Nil block_param, block_param=(block_param : Param | Nil) block_param=, block_param? : Param | Nil | Nil block_param?, body : Node body, body=(body : Node) body=, hash(hasher) hash, name : String name, name=(name : String) name=, params : Array(Param) params, params=(params : Array(Param)) params=, return_type : Node | Nil return_type, return_type=(return_type : Node | Nil) return_type=, return_type? : Node | Nil | Nil return_type?, splat_index : Int32 | Nil splat_index, splat_index=(splat_index : Int32 | Nil) splat_index=, splat_index? : Int32 | Nil | Nil splat_index?, static=(static : Bool) static=, static? : Bool static?

Constructor methods inherited from class Myst::Def

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) new

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(params = [] of Param, body = Nop.new, *, return_type = nil, block_param = nil, splat_index = nil, style : Symbol = :brace) #

[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 hash(hasher) #
Description copied from class Reference

See Object#hash(hasher)


def style : Symbol #

Style should be :doend or :brace, respectively, based on the bracing style used, as shown above.


[View source]
def style=(style : Symbol) #

Style should be :doend or :brace, respectively, based on the bracing style used, as shown above.


[View source]