enzo90
|
  |
| Joined: 25 Mar 2012 |
| Total Posts: 7104 |
|
|
| 27 Aug 2016 10:10 PM |
myt={0,8,10,1,3,5,7,9}
print( table.sort(myt), table.concat(myt, " ")) |
|
|
| Report Abuse |
|
|
|
| 27 Aug 2016 10:12 PM |
myt={0,8,10,1,3,5,7,9}
table.sort(myt) print( table.concat(myt, " "))
|
|
|
| Report Abuse |
|
|
Kodran
|
  |
| Joined: 15 Aug 2013 |
| Total Posts: 5330 |
|
|
| 27 Aug 2016 10:12 PM |
| table.sort returns nil, my dude! |
|
|
| Report Abuse |
|
|
enzo90
|
  |
| Joined: 25 Mar 2012 |
| Total Posts: 7104 |
|
|
| 27 Aug 2016 10:14 PM |
^^ Thanks.
I feel sad that in my two-three years of scripting, I haven't really touched tables enough to understand them. This really helps me in understanding it, so that I can be able to make more complex games.
Thanks guys! :) |
|
|
| Report Abuse |
|
|
Kodran
|
  |
| Joined: 15 Aug 2013 |
| Total Posts: 5330 |
|
|
| 27 Aug 2016 10:26 PM |
| you can also use unpack instead of table.concat |
|
|
| Report Abuse |
|
|
|
| 27 Aug 2016 10:51 PM |
table.sort will sort the table and return nil
so it will store the new stuff into the old table |
|
|
| Report Abuse |
|
|
|
| 27 Aug 2016 10:56 PM |
| It doesn't "return nil", it returns nothing. There's a difference. |
|
|
| Report Abuse |
|
|
Kodran
|
  |
| Joined: 15 Aug 2013 |
| Total Posts: 5330 |
|
|
| 27 Aug 2016 10:56 PM |
Oh really? That's super cool!!! I'd be really happy that you shared that information, except that this thread has already been solved and everything you say is useless :/
oops |
|
|
| Report Abuse |
|
|
enzo90
|
  |
| Joined: 25 Mar 2012 |
| Total Posts: 7104 |
|
| |
|
|
| 27 Aug 2016 11:40 PM |
| there is a difference but it is treated the same way in lua |
|
|
| Report Abuse |
|
|
|
| 27 Aug 2016 11:41 PM |
| so technically it does not return nil but the value returned from it is nonexistent so is replaced by nil |
|
|
| Report Abuse |
|
|
|
| 27 Aug 2016 11:45 PM |
"there is a difference but it is treated the same way in lua" no it's not |
|
|
| Report Abuse |
|
|
|
| 27 Aug 2016 11:45 PM |
yes it is
function hi()
end
function hi2() return nil end
print(hi()) print(hi2()) |
|
|
| Report Abuse |
|
|
|
| 27 Aug 2016 11:46 PM |
You're using an awful example, if you understood Lua you would know why what you posted it not proof.
print(type(print())) print(type(nil))
I would give a technical explanation but I don't feel like you would care (since you're stubborn and arrogant, after all) |
|
|
| Report Abuse |
|
|
|
| 27 Aug 2016 11:46 PM |
| #################################### |
|
|
| Report Abuse |
|
|