Skip to content

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

instance method

RubyVM::InstructionSequence#label

() -> ::String
label

Returns the label of this instruction sequence.

<main> if it’s at the top level, <compiled> if it was evaluated from a string.

For example, using irb:

Example
iseq = RubyVM::InstructionSequence.compile('num = 1 + 2')
#=> <RubyVM::InstructionSequence:<compiled>@<compiled>>
iseq.label
#=> "<compiled>"

Using ::compile_file:

# /tmp/method.rb
def hello
  puts "hello, world"
end

# in irb
> iseq = RubyVM::InstructionSequence.compile_file('/tmp/method.rb')
> iseq.label #=> <main>
See also #inspect #node_id #first_lineno #path also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0