eval.in

Paste #36676

Ruby — MRI 2.0.0, pasted 3 years ago

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
def no_docstring
  nil
end

def with_docstring
  """Foo"""
  nil
end

puts RubyVM::InstructionSequence.of(method(:no_docstring)).disasm
puts "---"
puts RubyVM::InstructionSequence.of(method(:with_docstring)).disasm

Program Output

== disasm: <RubyVM::InstructionSequence:no_docstring@/tmp/execpad-ecb5745fbd46/source-ecb5745fbd46>
0000 trace            8                                               (   1)
0002 putnil           
0003 trace            16                                              (   3)
0005 leave            
---
== disasm: <RubyVM::InstructionSequence:with_docstring@/tmp/execpad-ecb5745fbd46/source-ecb5745fbd46>
0000 trace            8                                               (   5)
0002 putnil           
0003 trace            16                                              (   8)
0005 leave            

OK (0.032 sec real, 0.037 sec wall, 8 MB, 41 syscalls)

Fork