> I don't think that code snippets presented without motivation, explanation, or commentary are an effective way to teach.

I agree, they are not.

However it took me a better part of today  to write this snippet.

If I saw it as it is, I could proceed with my coding task without delay.

I posted it just in case someone faces a similar problem and could benefit from it.

This is to complement other available materials, not to replace them.