[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: lua-l@...
- From: Xavier Wang <weasley.wx@...>
- Date: Sat, 7 May 2016 18:17:13 +0800
2016-05-07 18:12 GMT+08:00 Daurnimator <quae@daurnimator.com>:
> 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.