Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Which is better?


  • Total voters
    15
What is ; in swift.

I’m trying playground for 1st time.
Is there a list of shift commands such as ;
Funny 1st lesson doesn’t actuallly mention to enter ; until I my code wouldn’t run without ;
Swift doesn’t require the semicolon; it only requires it if there are multiple statements on one line. Otherwise, it infers it from a line break. (You can still use semicolons if you’re more comfortable doing so, but it isn’t required if you have separate statements on separate lines.)
 
  • Like
Reactions: Donfor39
Swift doesn’t require the semicolon; it only requires it if there are multiple statements on one line. Otherwise, it infers it from a line break. (You can still use semicolons if you’re more comfortable doing so, but it isn’t required if you have separate statements on separate lines.)
Thanks for taking your time to explain.
Playground 1st excersise wouldn’t run without semicolon being used

E.g.
moveForward();
moveForward();
moveForward();
collectGem()

Whereas the hint didn’t mention the semicolon at all
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.