Difficult to write an explanation that's anywhere near as short as the code. I'll try to give a basic overview.
The idea is that
term - the
table that holds all the
functions you use to write to the default display - can be replaced by a table of functions that write to a
different display (using
term.redirect()).
When you
wrap an external monitor, you get a table filled with functions that write to that monitor (
peripheral.find() offers a way to wrap lots of peripherals of a similar type quickly). This is an example of the sort of table you might redirect term to.
So, the code works by first filling a table with wrapped monitor tables, then generating a
new table containing one function for every function which exists in those monitor tables (using an
iterator for loop) - these new functions run the equivalent functions on
all wrapped monitors when you call them, using another for loop.
The end result is a table that you can redirect the terminal to that'll result in all subsequent screen writes being performed on all your attached monitors.
You could, if you wanted, use this table without redirecting to it. For example, if you skipped out on the term.redirect(multiTerm) line, you could instead use commands like multiTerm.setCursorPos(1,1) or multiTerm.write("whatever") to deal with the collection of monitors.
The benefit of redirecting is that certain commands - such as
print(), which handles display scrolling and word-wrap for you, as well as all the commands in the
paintutils API - will only work on the current terminal.