fork download
  1. local function contains(tabela, valor)
  2. for i = 1, #tabela do
  3. if tabela[i] == valor then
  4. return true
  5. end
  6. end
  7. return false
  8. end
  9.  
  10. local names = {"joão", "maria", "josé"}
  11. if not contains(names, "carlos") then
  12. table.insert(names, "carlos")
  13. end
  14. for i = 1, #names do
  15. print(names[i])
  16. end
  17.  
  18. --https://pt.stackoverflow.com/q/339407/101
Success #stdin #stdout 0s 14112KB
stdin
Standard input is empty
stdout
joão
maria
josé
carlos