| |
|
|
| 04 Dec 2014 03:48 PM |
It returns a value. (Oops, I broke the rule)
Don't use functions for this, but here is an example.
function Example() return 5 end
print(Example()) ->5
Here's another example, this one is better to use than the previous.
function Example2(Num1, Num2) return Num1 + Num2 end
print(Example2(5, 7)) ->12 |
|
|
| Report Abuse |
|
|
| |
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 04 Dec 2014 03:52 PM |
| It gives a function value. |
|
|
| Report Abuse |
|
|
| |
|
C0D3Y
|
  |
| Joined: 24 Jul 2010 |
| Total Posts: 1692 |
|
|
| 04 Dec 2014 03:54 PM |
The most common examples I've seen are when you set a variable equivalent to the function. Example:
function Add(num1,num2) return num1 + num2 end
sum = Add(2,5)
print(sum)
Or something like that. Depending on your style, you can probably get away with never using it. It's mostly used when you're using the function repeatedly with different outcomes, but you want the same effect. I'm probably doing a poor job explaining it, but hopefully you get the gist of it. |
|
|
| Report Abuse |
|
|
| |
|
|
| 04 Dec 2014 03:56 PM |
it turnres something
eg;
local add=function(a,b) return a+b end
print(add(1,1)) --> 2 |
|
|
| Report Abuse |
|
|
WishNite
|
  |
| Joined: 11 Feb 2009 |
| Total Posts: 15828 |
|
|
| 04 Dec 2014 04:01 PM |
note: this is inefficient as you can be using table functions like table.sort
table = {7,5,3,2,6} function findhighestvalue() local highest = 0 for _,number in ipairs(table) do if number > highest then highest = number end end return highest end
print(findhighestvalue()) >7 |
|
|
| Report Abuse |
|
|
|
| 04 Dec 2014 04:05 PM |
| I already gave you two examples that should explain it entirely. |
|
|
| Report Abuse |
|
|