Skip to content

Latest commit

 

History

History
27 lines (19 loc) · 368 Bytes

trigger-irb-as-needed.md

File metadata and controls

27 lines (19 loc) · 368 Bytes

Trigger irb as needed

require 'irb'

def my_program_context
  @my_program_context ||= Struct.new(:value).new(40)
end

trap(:INT) do
  IRB.start
  trap(:INT, 'EXIT')
end

loop do
  p "Current value: #{my_program_context.value}"
  sleep 1
end

# Result:
# "Current value: 40"
# "Current value: 40"

View Source