Earlier this problem. For multiple return function
fn=function() return 'a','b' end
call
print(fn()) returns ab
print(fn())
ab
but a challenge
print(fn() or nil) returns only a
print(fn() or nil)
a
why? or doesn't matter since the first call was successful correctly?
or
Quoting from Programming in Lua Β§5.1 - Several results
Lua always adjusts the number of results from a function to the circumstances of the call. When we call a function as an instruction, Lua drops all results from the function. When we use the call as an expression, Lua only saves the first result. We get all the results only when the call is the last (or only) expression in the list of expressions.
In the case of your example, the return value of fn() used as an expression (the left operand of the or operator), so only the first value is stored.
fn()
Source: https://habr.com/ru/post/958036/More articles:the drop-down list in the navigation bar does not expand (bootstrap, angular, directives, routes) - javascriptCDI + driven concurrency in Java EE 7 - javaStrange Warnings in Web.config - .netUsing Jasig Central Authentication Service (CAS) with ASP.NET MVC 4/5 - c #try to kill all the nodes, but did not work on osx - node.jsCannot resolve "ok (?)" Method with Play 2 Framework in Intellij - intellij-ideaHow to use a barcode scanner as a keyboard in iOS? - iosGingerbread devices not using Holo style from Theme.AppCompat (support library) - androidUse the cool Holo theme / style on gingerbread cookies - androidcompatible variable length structure in C ++ - c ++All Articles