How to iterate with a table in Lua?

Asked

Viewed 111 times

4

How to iterate with a table in Lua?

Example:

dados = {
    nome = 'Wallace',
    idade = 25
}
  • Now that you’re learning Moon, take a look at all the questions from tag, There are many things that have already been answered. Now that I have found this. And don’t forget to vote for all the good things you find in all the questions: http://answall.com/questions/tagged/lua?sort=votes&pageSize=50

1 answer

5


  • I was seeing that there’s this one foreach, foreachi and foreachvar. That’s in old versions?

  • Show me where you’re seeing this, I don’t know.

  • http://www.fabricadigital.com.br/media/Curso_Lua.pdf

  • 1

    Note that they are functions and not commands. The command is for. The functions can be used, of course, they will receive Amble as parameters. The function semantics is a little different from the command, but it solves most situations well. In general I would avoid. This is almost the same as preferring jQuery to JS :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.