Guide: patterns.

Fixes #4417.
I don't have a lot of experiene using `ref`, so an example of when this is actually used would be helpful.