servo.attach

The servo object is defined globally so it does not matter where the attach() is done the servo object will still be available globally and the servo object will have a private variable holding the pin number to be used.

According to the Arduino tutorial on LEDs at the very last part,

Can you please provide a link to this advice