the sweep example, is another of the "how not to design code" examples.
It does what it sets out to do, which is to sweep a servo through 180 degrees in each direction. It is not presented as an example of good programming practice and if it were written as non blocking code many users looking at it for the first time would be bamboozled for sure.
What would have been better would be to include 2 versions, one as now and a second non blocking version with an explanation of why it is better in some circumstances. The examples, particularly those included with libraries, are examples of how things can
be done, not necessarily how they should
be done. This may be a shame but it is a fact.