The implicit "arg" parameter in functions that do not work in Lua

I have a problem using implicit parameter argin functions.

The code does not work. The documentation http://www.lua.org/pil/5.2.html should work.

function listar_um (...)
  for i,v in ipairs(arg) do
    print("usando args " .. arg[i])  
  end
end
listar_um("Olรก", 1, "Dois")

This code works with a declaring variable lista.

function listar_um (...)
  lista = {...}

  for i,v in ipairs(lista) do
    print("nรฃo usando args " .. lista[i])  
  end
end
listar_um("Olรก", 1, "Dois")

Why does the first example not work?

Script for the test: http://www.codeshare.io/IPwRJ Run the on-line script: http://www.compileonline.com/execute_lua_online.php

Thank.

+4
source share
1 answer

The first release of PiL talks about Lua 5.0. Usage is argavailable in Lua 5.0, while it is removed from Lua 5.1

Lua 5.0, Lua 5.1.

- Lua 5.2, print(_VERSION).


: , arg - Lua 5.1, Lua 5.2.

+4

All Articles