class Crystal::Def
inherits Crystal::ASTNode
¶
A method definition.
'def' [ receiver '.' ] name
body
'end'
| 'def' [ receiver '.' ] name '(' [ arg [ ',' arg ]* ] ')' body 'end'
Included modules
Crystal::Annotatable
Crystal::HookExpansionsContainer
Direct known subclasses
Crystal::External
Class methods¶
.new(name, args = [] of Arg, body = nil, receiver = nil, block_arg = nil, return_type = nil, macro_def = false, yields = nil, abstract __arg24 = false, splat_index = nil, double_splat = nil, free_vars = nil)
¶
(name, args = [] of Arg, body = nil, receiver = nil, block_arg = nil, return_type = nil, macro_def = false, yields = nil, abstract __arg24 = false, splat_index = nil, double_splat = nil, free_vars = nil)
Methods¶
#==(other : self)
¶
(other : self)
Returns true
if this reference is the same as other. Invokes same?
.
#c_calling_convention?
¶
Returns self
as an External
if this Def is an External
that must respect the C calling convention.
#doc : String?
¶
: String?
Returns the doc comment attached to this node. Not every node
supports having doc comments, so by default this returns nil
.
#hash(hasher)
¶
(hasher)
#interpret(method : String, args : Array(ASTNode), named_args : Hash(String, ASTNode)?, block : Crystal::Block?, interpreter : Crystal::MacroInterpreter, name_loc : Location?)
¶
(method : String, args : Array(ASTNode), named_args : Hash(String, ASTNode)?, block : Crystal::Block?, interpreter : Crystal::MacroInterpreter, name_loc : Location?)
#match
¶
Yields arg, arg_index, object, object_index
corresponding
to arguments matching the given objects, taking into account this
def's splat index.
#min_max_args_sizes
¶
Returns the minimum and maximum number of arguments that must be passed to this method.