Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

instance method

Thread::Backtrace::Location#label

() -> ::String?
label

Returns the label of this frame.

Usually consists of method, class, module, etc names with decoration.

Consider the following example:

Example
def foo
  puts caller_locations(0).first.label

  1.times do
    puts caller_locations(0).first.label

    1.times do
      puts caller_locations(0).first.label
    end
  end
end

The result of calling foo is this:

foo
block in foo
block (2 levels) in foo
See also #inspect #lineno #base_label #path also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0