How to write a function which returns itself in an extend class?

In reply to cgales:

Thank you for this answer !