CodeQL library for Ruby
codeql/ruby-all 0.8.15-dev (changelog, source)
Search

Member predicate IfExpr::getElse

Gets the elsif/else branch of this if/elsif expression, if any. In the following example, the result is a StmtSequence containing b.

if foo
  a
else
  b
end

But there is no result for the following:

if foo
  a
end

There can be at most one result, since elsif branches nest. In the following example, ifExpr.getElse() returns an ElsifExpr, and the else branch is nested inside that. To get the StmtSequence for the else branch, i.e. the one containing c, use getElse().(ElsifExpr).getElse().

if foo
  a
elsif bar
  b
else
  c
end
Stmt getElse()