IRB supports multiple concurrent sessions. You can enter the IRB command in IRB to start a new sub-session. There is only one current session. You can use the jobs command to list all dialogs and use the FG command to switch to another (sleep) session.
Different sub-sessions maintain different variable spaces (variables with the same name have their own values ).
Each sub-session uses its own session prompt. The primary session is indicated by IRB, and other subsessions are represented by IRB #1 and IRB #2. If an object is specified as a parameter during a promoter Session, the object is bound to the self object of the session as the default object of the session. At the same time, the prompt is also reflected.
D: \> irbirb (main): 001: 0> irbirb #1 (main): 001: 0> IRB "another" IRB #2 (another): 001: 0> jobs => #0-> IRB on main (# <thread: 0x34cc748>: Stop) #1-> IRB #1 on main (# <thread: 0x3a49e8c>: stop) #2-> IRB #2 on another (# <thread: 0x3a43a78>: Running) IRB #2 (another): 002: 0> FG 1 = >#< IRB:: IRB: @ signal_status =: in_eval, @ region = # <rubylex: 0x3a49e00>, @ context = # <IRB: Context: 0x3a49e14> IRB #1 (main ): 002: 0> jobs =># 0-> IRB on main (# <thread: 0x34cc748>: Stop) #1-> IRB #1 on main (# <thread: 0x3a49e8c>: Running) #2-> IRB #2 on another (# <thread: 0x3a43a78>: Stop) IRB #1 (main): 003: 0> exit = ># <IRB: @ signal_status =: in_eval, @ region = # <rubylex: 0x3a581bc>, @ context = # <IRB: context: 0x3a58518> IRB (main): 002: 0> jobs => #0-> IRB on main (# <thread: 0x34cc748>: running) #2-> IRB #2 on another (# <thread: 0x3a43a78>: Stop) IRB (main): 003: 0>
Session management Commands include:
- IRB [object]
Start a new sub-session and use "object" as the default object to bind (Self)
- jobs
display session List
- CB object
replace a new object binding
- FG session ID
switch to a subsession. The session ID can be a session number, thread ID, IRB object, or bound object.
- kill session ID
kill a subsession. The session is marked as above.
- exit
exit the current sub-session