Method: Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>TaslemGuy
Created the page. Please improve, might not be to Wiki Standard.
>TaslemGuy
Minor mistake in formatting was corrected.
Line 6: Line 6:
These two codes call the same function (a) with the same parameters (b).
These two codes call the same function (a) with the same parameters (b).


<pre>  
<pre>b.a(b)  
b.a(b)  
b:a()  
b:a()  
</pre>  
</pre>  

Revision as of 14:27, 23 December 2010

Introduction

Methods are functions which belong to a particular object. Although standard Lua doesn't have them, they're a major focus of Roblox Lua. Methods act like a function stored within an object. The method itself is accessed in the same way a Function in a Table is accessed. However, a special property of methods changes how they are called.

These two codes call the same function (a) with the same parameters (b).

b.a(b) 
b:a() 

The second is more brief and concise. Methods can increase typing speed, because there is less need to retype variable names. Methods may or may not return data.

Examples

All instances (possibly excluding) some core services, have the remove method, along with the clone method. Sounds have the Play method and the Stop method.