Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
Prism::DesugarCompiler#desugar_or_write_defined_node
desugar_or_write_defined_node(node, read_class, write_class, *arguments)
lib/prism/desugar_compiler.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.3.0/lib/prism/desugar_compiler.rb, line 187
def desugar_or_write_defined_node(node, read_class, write_class, *arguments)
IfNode.new(
node.operator_loc,
DefinedNode.new(nil, read_class.new(*arguments, node.name_loc), nil, node.operator_loc, node.name_loc),
node.operator_loc,
StatementsNode.new([read_class.new(*arguments, node.name_loc)], node.location),
ElseNode.new(
node.operator_loc,
StatementsNode.new(
[write_class.new(*arguments, node.name_loc, node.value, node.operator_loc, node.location)],
node.location
),
node.operator_loc,
node.location
),
node.operator_loc,
node.location
)
end
Desugar ‘x ||= y` to `defined?(x) ? x : x = y`