The block was evaluated twice, even though the array had but one element:
The array: ["l"]
PROCESSING "l"
PROCESSING nil
t.rb:7:in `eval': can't convert nil into String (TypeError)
from t.rb:7:in `e'
from t.rb:5:in `e'
from t.rb:12
I finally tracked it down to this function, which was being executed on
RUBY_EVENT_(C)_RETURN events:
Methods taking a block and implemented in C, at risk
If the key is not found, rb_hash_delete will yield it to the current block,
if present.
But which block is that? It's harder to see in C...
That would be the block passed to the current method, i.e. the one you
rb_define_method()'d. Or, in this particular case, the method we were
returning from (remember this was being executed in an event_hook).
This means that you have to be careful whenever you use a function from Ruby's C API that admits a
block and you do not want one passed.
The fix looks like this: