lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



> I do not see any issue here.
> newlines are insignificant in lua. your example is the same as:
>
> print("hello")(function() print"world" end)()
>
> i.e.
> 1. call print with "hello",
> 2. call the result of that with an argument of a function
> 3. call the result of that with no arguments.
>
> As the result of print is nothing; at step 2 you attempt to call
> `nil`, and hence get the (correct) error message.
>


And if you want to call a annoy function or methods on string or other
literal (need parentheses), you use add a ; before, like this:

print "hello"
;(function() print "world" end)()

--
regards,
Xavier Wang.



Oh, I got it. I just understand. It's not a bug but corner case.
Thank you :)

--
Kawahara Satoru
College of Information Science
University of Tsukuba