Noob question regarding servo.write in and outside of for loop

So I'm working on a hexapod robot, and I'm curious as to why I've seen code used with the following:

  for(pos = 0; pos < 180; pos += 1)  // goes from 0 degrees to 180 degrees 
  {                                  // in steps of 1 degree 
    myservo.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(15);                       // waits 15ms for the servo to reach the position 
  }

versus simply just using

{
  myservo.write(180);
}

Don't both of these accomplish the same thing, but the first one just in a slower manner? Or is there a technical / electrical reason you dont want to just use the simpler piece of code on the bottom? Many thanks for clearing up the confusion!

Don't both of these accomplish the same thing, but the first one just in a slower manner? Or is there a technical / electrical reason you dont want to just use the simpler piece of code on the bottom? Many thanks for clearing up the confusion!

Your correct that both methods end up at the same position, it's just that the first wants the servo to move in steady timed steps while your method allows the servo to determine how fast it can move to the end position. Both are valid methods depending on what one is trying to accomplish. A servos maximum speed can vary a lot between all the different servo models out there and there can be valid reasons one wants to control the speed of the servo movement rather then letting the servo just run at it's max skew rate.

Lefty

Ah brilliant, thank you. I was thinking it might be something that simple, but I wasnt sure, and wanted to be positive. I appreciate the quick answer!