UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Weird question

Forums > SwiftUI

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

2      

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

2      

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....

2      

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.

2      

Hacking with Swift is sponsored by RevenueCat

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

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

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

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.