Skip to content

class Crystal::If
inherits Crystal::ASTNode

An if expression.

'if' cond
  then
[
'else'
  else
]
'end'

An if elsif end is parsed as an If whose else is another If.

Class methods

.new(cond, a_then = nil, a_else = nil, ternary = false)

View source

Methods

#==(other : self)

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

#accept_children(visitor)

View source

#and=(and)

This is set to true for an If that was created from an && expression.

View source

#and? : Bool

This is set to true for an If that was created from an && expression.

View source

#clone_without_location

View source

#cond=(cond : ASTNode)

View source

#else=(else : ASTNode)

View source

#falsey=(falsey)

This is set to true when the compiler is sure that the condition is falsey

View source

#falsey? : Bool

This is set to true when the compiler is sure that the condition is falsey

View source

#hash(hasher)

#interpret(method : String, args : Array(ASTNode), named_args : Hash(String, ASTNode)?, block : Crystal::Block?, interpreter : Crystal::MacroInterpreter, name_loc : Location?)

View source

#or=(or)

This is set to true for an If that was created from an || expression.

View source

#or? : Bool

This is set to true for an If that was created from an || expression.

View source

#ternary=(ternary : Bool)

View source

#ternary? : Bool

View source

#then=(then : ASTNode)

View source

#truthy=(truthy)

This is set to true when the compiler is sure that the condition is truthy

View source

#truthy? : Bool

This is set to true when the compiler is sure that the condition is truthy

View source