Refactored example to Option.collect method.
Merge pull request #3898 from adriaanm/jxcoder-issue-3861

Refactored example to Option.collect method.