Removed useless else in code example
Removed useless return
minor #3511 [Component-DI] Removed useless else statement in code example (saro0h)

This PR was submitted for the master branch but it was merged into the 2.3 branch instead (closes #3511).

Discussion
----------

[Component-DI] Removed useless else statement in code example

Commits
-------

edca0c7 [Component-DI] Removed useless return
24c4370 [Component-DI] Removed useless else in code example