lua-users home
lua-l archive

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

On Wed, Feb 19, 2014 at 08:56:32AM -0800, Steven Mak wrote:
> Hi all,
> Can I know why there is no such operators as ++ or += (or similarly others like string concatenation) in Lua? What are the better alternatives instead of writing it in full "x = x + 1" or "this_string = this_string .. "Another string ""? 

An age old question.  The trick is to set up some macros/snippets in
your text editor if you want to save the handful of keypresses.  (I'm
surprised neither of the FAQs cover this.)

As for why they don't exist, there are some interesting corner
cases/possible surprises related to metamethods that are entirely
avoided by being specific.