class Myst::Block
- Myst::Block
- Myst::Def
- Myst::Node
- Reference
- Object
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.crConstructors
Instance Method Summary
-
#==(other : self)
Returns
true
if this reference is the same as other. -
#hash(hasher)
See
Object#hash(hasher)
-
#style : Symbol
Style should be
:doend
or:brace
, respectively, based on the bracing style used, as shown above. -
#style=(style : Symbol)
Style should be
:doend
or:brace
, respectively, based on the bracing style used, as shown above.
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
Instance Method Detail
Returns true
if this reference is the same as other. Invokes same?
.
Style should be :doend
or :brace
, respectively, based on the bracing
style used, as shown above.
Style should be :doend
or :brace
, respectively, based on the bracing
style used, as shown above.