Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

String split returns nil value error in lua

Tags:

lua

I'm following a lua doc page on string splitting, get an error trying it myself. For example,

Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
split("a,b,c", ",") 

returns

stdin:1: attempt to call global 'split' (a nil value)
stack traceback:
stdin:1: in main chunk
[C]: ?

Why is this so?

like image 470
Leke Avatar asked Sep 08 '26 12:09

Leke


1 Answers

That isn't a "lua doc page". It is a wiki article explaining the concept of splitting and joining strings, not any actual functions in Lua. The Lua documentation clearly states that there is no "split" function. The wiki article is explaining how to create such a function and/or how such a function might work.

like image 199
Nicol Bolas Avatar answered Sep 11 '26 22:09

Nicol Bolas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!