class Opal::Nodes::Args::ExtractOptargNode

Compiles extraction of a single inline optional argument def m(a = 1); end

^^^^^

This node doesn’t exist in the original AST, InlineArgs rewriter creates it to simplify compilation

Sometimes the argument can’t be inlined. In such cases InlineArgs rewriter replaces

s(:optarg, :arg_name, ...default value...)

to:

s(:fakearg) + s(:extract_post_optarg, :arg_name, ...default value...)

Public Instance Methods

compile() click to toggle source
# File lib/opal/nodes/args/extract_optarg.rb, line 25
def compile
  return if default_value.children[1] == :undefined

  push "if (#{name} == null) #{name} = ", expr(default_value)
end