caca50
|
  |
| Joined: 10 Jul 2011 |
| Total Posts: 2037 |
|
|
| 15 Nov 2016 05:58 PM |
How can I return multiple values from a function?
Similar to how string.find() will return the starting point, and ending point:
local s = "Hi guys, I'm caca50"
local b,e = string.find(s,'caca')
print(b..' '..e) >>14 17 |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 15 Nov 2016 06:00 PM |
split everything you're returning by commas:
function mathOp(a, b) return a + b, a - b, a * b, a / b end
print(mathOp(4, 5))
|
|
|
| Report Abuse |
|
|
caca50
|
  |
| Joined: 10 Jul 2011 |
| Total Posts: 2037 |
|
| |
|