I understand that there are these two idioms “in_thread do loop do whatever end end” and “live_loop do whatever end” taking care of thread creation and looping all in one fell swoop.
I am wondering: How can I create a thread-local variable in a live loop AND INITIALIZE it before looping? As it looks to me I would have to write:
in_thread(name: :thread_name) do
idx = 42
because in a live_loop, the variable would be initialised on every cycle. But the “in_thread do loop do end end” idiom doesn’t support live coding, meaning I have to stop and restart playback every time I make a change to my loop. What can I do here?