как работает оператор in

leekyrave

Известный
Автор темы
413
227
Версия MoonLoader
Другое
Как работает оператор "in" в lua и как составить ретурн функции, чтобы возвращаемое значение подходило для оператора in?
Мне ради интереса, на данный момент мне достаточно и обычного возвращаемого массива и перебор через for k,v do end

пон
 
Последнее редактирование:
Решение
John Zwinck написал(а):
Lua's in is not a function or a variable. It's a part of the syntax for flow control. You can't replace it, you can't copy it, you can't even refer to it. It's rather like parentheses: a syntactic construct which has meaning for how a program is parsed, but which cannot be referred to within the program.

It doesn't "return" anything. It doesn't have "logic." It's more like a placeholder, or punctuation.
https://stackoverflow.com/a/28312770

Cosmo

Известный
Друг
661
2,826
John Zwinck написал(а):
Lua's in is not a function or a variable. It's a part of the syntax for flow control. You can't replace it, you can't copy it, you can't even refer to it. It's rather like parentheses: a syntactic construct which has meaning for how a program is parsed, but which cannot be referred to within the program.

It doesn't "return" anything. It doesn't have "logic." It's more like a placeholder, or punctuation.
https://stackoverflow.com/a/28312770
 
  • Нравится
Реакции: leekyrave