When should I use "semicolon" at the end of the line?

Hello guys, 

I am coming from a PHP programming background, just started learning Corona and kind of I am loving it. When review some sample codes and in some tutorials, I see some lines end with semicolon , but some lines don’t.  

When should we add semicolon at the end of the line?

for example, in sample codes, in SampleCode/Physics/EggBreaker/main.lua

we have this code

local arrow = display.newImage( "arrow.png", 50, 120 ) game:insert( arrow ); 

Why the first line doesn’t have semicolon, but second line has semicolon?

Thanks for your help :slight_smile:

It’s all up to you. :slight_smile:
http://www.coronalabs.com/blog/2012/10/31/faq-wednesday-lua-programming-tips/

Cheers!

-Saer

The semi-colon is only required if you are putting multiple statements on one line:

a = 10; b = 20; c = 30

This will frequently be needed when doing closures/anonymous functions:

transition.to(myObj, { alpha=0; onComplete=function(target) target:removeSelf(); target = nil; end })

Other than that, they are optional.

Rob

Thank you so much guys, that’s what I was looking for  :slight_smile:

This forum is awesome, very fast replying.

Cheers,

Andy

It’s all up to you. :slight_smile:
http://www.coronalabs.com/blog/2012/10/31/faq-wednesday-lua-programming-tips/

Cheers!

-Saer

The semi-colon is only required if you are putting multiple statements on one line:

a = 10; b = 20; c = 30

This will frequently be needed when doing closures/anonymous functions:

transition.to(myObj, { alpha=0; onComplete=function(target) target:removeSelf(); target = nil; end })

Other than that, they are optional.

Rob

Thank you so much guys, that’s what I was looking for  :slight_smile:

This forum is awesome, very fast replying.

Cheers,

Andy