| View previous topic :: View next topic |
| Author |
Message |
KawaGeo
Joined: 27 Aug 2005 Posts: 191 Location: Calif Mountains
|
Posted: Mon Aug 29, 2005 4:55 am Post subject: Colon or Period? |
|
|
In the functions.txt file, many have colon and others, period. For example,
| Code: | Image Image.load( filename )
nil Image:save( filename ) |
I am somewhat confused between them. Can anyone explain the difference?
It is hard to remember which to use colon or period without understanding why.
Thanks. _________________ Geo Massar
Retired Engineer |
|
| Back to top |
|
 |
Shine
Joined: 03 Dec 2004 Posts: 728 Location: Germany
|
Posted: Mon Aug 29, 2005 5:10 am Post subject: Re: Colon or Period? |
|
|
| Dots are used for kind of static functions, without an object, and colons are used, when calling a function on an object. E.g. i=Image.load("test.png") creates an object and i:save("image.tga") saves it and is a short form for Image.save(i, "image.tga"). |
|
| Back to top |
|
 |
KawaGeo
Joined: 27 Aug 2005 Posts: 191 Location: Calif Mountains
|
Posted: Mon Aug 29, 2005 6:46 am Post subject: |
|
|
Reply in a nutshell, indeed. :)
Thanks. _________________ Geo Massar
Retired Engineer |
|
| Back to top |
|
 |
Shine
Joined: 03 Dec 2004 Posts: 728 Location: Germany
|
Posted: Mon Aug 29, 2005 6:56 am Post subject: |
|
|
| You can find the glory details in the Lua manual ( http://www.lua.org/manual/5.0/ ) and your dot and colon question at http://lua-users.org/wiki/SimpleLuaClasses . Lua Player uses something like the simple class model for Image, Music etc. internally, so it is not a pure Lua question, which is the reason why I didn't locked this thread :-) |
|
| Back to top |
|
 |
|