The idea is as follows ->
suppose one defines a simple regular expression as follows
r = '(a)|(b)|(c)'
re = Regexp.new(r)
This re can be used with either String.match. The String.match returns a MatchData object. Often one is interested in an array. which can be obtained by String.scan instead of String.match. However this array is actually an array of Arrays, with "nil" at places where the string doesn't match..
[["a", nil, nil], [nil, "b", nil], [nil, nil, "h"]]
If one just wants the array as ["a", "b", "c"], one could use following trick.
The flatten flattens out the array and compact gets rid of all nil
pretty useful .. One can then iterate over this array. Somehow this convenience is not offered by MatchData or atleast I don't know of it.