Implicit items/pairs invocations
If the for loop expression e does not denote an iterator and the for loop has exactly 1 variable, the for loop expression is rewritten to items(e); i.e. an items iterator is implicitly invoked:
for x in [1,2,3]: echo x
If the for loop has exactly 2 variables, a pairs iterator is implicitly invoked.
Symbol lookup of the identifiers items/pairs is performed after the rewriting step, so that all overloads of items/pairs are taken into account.
当前内容版权归 nim-lang.org 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 nim-lang.org .