Forums

ForumsProgramming Forum

A trick?

Posted May 1, '12 at 5:42pm

XxSoupXSoupxX

XxSoupXSoupxX

7 posts

I noticed when changing cords you don't need to add a ; at the end of every line, I'm just taking class so I don't know if you guys already knew this, Also I found out sometimes you don't need (); at the end of certain lines lol

 

Posted May 3, '12 at 5:06am

Secretmapper

Secretmapper

740 posts

Not really a trick...

It is in fact not needed to write a semicolon at the end of every line, but it is considered good practice to do so. This is because some PL needs semicolons at the end of every line, and also note that if you do not add semicolons, sometimes you will end up passing functions as parameters themselves, among other things.

For the (); bit, well for certain lines it is not needed. I'm not just sure what you meant by the 'certain lines'

 

Posted May 4, '12 at 12:28am

Homework

Homework

15 posts

I know how to do a coin trick. Does that count?

 

Posted May 4, '12 at 4:25pm

pirateplatypusgames

pirateplatypusgames

40 posts

I was not aware that semi-colons can be optional. I thought it was mandatory, at least for languages like AS3 that use them.

 

Posted May 4, '12 at 7:36pm

PixelSmash

PixelSmash

567 posts

I knew some compilers/languages don't require the semicolon, in which case it's good practice. For most languages however it's required, and if your preferred coding program has a decent error check it should at least warn for it.

 

Posted May 5, '12 at 1:33am

Secretmapper

Secretmapper

740 posts

Well, to wrap it up, I just want to say when using AS3 (some other languages too), just go and terminate every statement with a semicolon. It's good practice for a reason, (such as my example above) and it actually helps you if you're line breaks becomes lost(this actually happens, and if you don't have semicolons, it'll be outright useless, of tiring to fix it.). It is also much harder to read code without semicolons.

And for one thing, a new line DOES NOT actually end a statement, so if you don't use semicolons, a compiler can actually think your code is just one big line!

 
Reply to A trick?

You must be logged in to post a reply!