I write ruby code. I have used snippets that I didn't fully understand. It turn out in the usual way "it works but I don't understand exactly how...". I ended with simpler code that I understand, was able to write test and all by reading the documentation.
Co-creator of Sourcegraph here. Just FYI, in addition to usage examples, we also display the documentation and fully-linked source code (so you can jump to definition, etc.)
Sometimes the documentation tells you exactly what you need. Sometimes you want an at-a-glance example. And sometimes you might want to dive into the source to figure out what's going on. Whatever it is you're doing to understand a piece of code, we want to make it as easy as possible.
Depends on the example, as other users said.