-
Notifications
You must be signed in to change notification settings - Fork 36
Open
Description
The methods is_a?
, kind_of?
and instance_of?
can be used in a conditional chaining expression, but cannot be converted to an equivalent Javascript expression.
if event && event.is_a?(Event)
puts "TEST"
end
if event&.is_a?(Event)
puts "TEST"
end
if event && event.kind_of?(Event)
puts "TEST"
end
if event&.kind_of?(Event)
puts "TEST"
end
if event && event.instance_of?(Event)
puts "TEST"
end
if event&.instance_of?(Event)
puts "TEST"
end
This is translated to
if (event?.is_a?(Event)) console.log("TEST");
if (event?.is_a?(Event)) console.log("TEST");
if (event?.kind_of?(Event)) console.log("TEST");
if (event?.kind_of?(Event)) console.log("TEST");
if (event?.instance_of?(Event)) console.log("TEST");
if (event?.instance_of?(Event)) console.log("TEST");
The correct translation would be
if (event && (event instanceof Event)) console.log("TEST");
if (event && (event instanceof Event)) console.log("TEST");
if (event && (event instanceof Event)) console.log("TEST");
if (event && (event instanceof Event)) console.log("TEST");
if (event && (event.constructor == Event)) console.log("TEST");
if (event && (event.constructor == Event)) console.log("TEST");
Metadata
Metadata
Assignees
Labels
No labels