Skip to content

Instantly share code, notes, and snippets.

@benoittgt
Last active November 14, 2018 15:58
tracepoint_equal_integer
x=[1,2,3];
TracePoint.new(:call, :c_call){ |tp|
puts "#{tp.defined_class} #{tp.method_id} #{tp.path}:#{tp.lineno}"
}.enable { x.index(2) }
# Array index (irb):4
# => 1
x=[1,2,3];
class Integer; def ==(_); super; end; end
# => :==
TracePoint.new(:call, :c_call){ |tp|
puts "#{tp.defined_class} #{tp.method_id} #{tp.path}:#{tp.lineno}"
}.enable { x.index(2) }
# Array index (irb):9
# Integer == (irb):5
# Comparable == (irb):5
# Integer <=> (irb):5
# => 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment