NEW: Learn to build amazing SwiftUI apps for macOS with my new book! >>

Weird question

Forums > SwiftUI

Do blank lines with no code make your program larger in size? Or does it really matter?

1      

Doesn't matter. The compiler strips out blank lines and comments when it builds your app.

1      

Ok thanks, I not sure where I got that into my head perhaps it was something I read last time I tried this coding thing. But that was "Apple Basic" so theres that....

1      

As @rooster points out, there is no impact on the final compiled size of your application. But I think blanks lines DO matter.

Blank lines help you segment groups of code together in logical chunks. For example, if you're formatting a message you might segregate those lines from others to help you visualize what you're doing. You don't need to insert a dice randomization function in the middle of your message formatting code.

This keeps logical groups of code away from each other. In later passes, you might consider reusing that small chunk of code elsewhere and refactor them as a function. YMMV.

But don't go overboard! In particular, if you're asking for help in this forum, please consider REMOVING blank lines from your problematic code. Instead insert lots of comments telling us what you're attempting to do. This can help us focus on both your logic and syntax.

1      

Hacking with Swift is sponsored by RevenueCat

SPONSORED Spend less time managing in-app purchase infrastructure so you can focus on building your app. RevenueCat gives everything you need to easily implement, manage, and analyze in-app purchases and subscriptions without managing servers or writing backend code.

Get Started

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.