ForumsProgramming ForumA trick?

5 1617
XxSoupXSoupxX
offline
XxSoupXSoupxX
7 posts
1,545

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

  • 5 Replies
Secretmapper
offline
Secretmapper
1,754 posts
370

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'

Homework
offline
Homework
17 posts
565

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

pirateplatypusgames
offline
pirateplatypusgames
40 posts
450

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

PixelSmash
offline
PixelSmash
569 posts
630

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.

Secretmapper
offline
Secretmapper
1,754 posts
370

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!

Showing 1-5 of 5