Page 1 of 1
Unary Operators
Posted: Thu Nov 03, 2016 1:56 pm
by sudo_radish
Is there a list of Unary operators that is used in Love?
Re: Unary Operators
Posted: Thu Nov 03, 2016 2:38 pm
by s-ol
You are looking for Lua's unary operators, not LÖVEs, since LÖVE isn't a language.
The lua reference lists the minus, length operator (#) and "not":
https://www.lua.org/manual/5.1/manual.html#2.5
Re: Unary Operators
Posted: Thu Nov 03, 2016 2:55 pm
by sudo_radish
Thanks for the feedback.
I did check the Lua docs first but I didn't know if Love had some modified stuff in it like Pico 8 does.
it is mainly because I am a touch lazy and I like the way I can do
or
over
.
Stupidly I tried it first and got a great big fat error on compile lol. And I didn't want to think I missed something obvious.
Re: Unary Operators
Posted: Thu Nov 03, 2016 3:21 pm
by s-ol
sudo_radish wrote:Thanks for the feedback.
I did check the Lua docs first but I didn't know if Love had some modified stuff in it like Pico 8 does.
it is mainly because I am a touch lazy and I like the way I can do
or
over
.
Stupidly I tried it first and got a great big fat error on compile lol. And I didn't want to think I missed something obvious.
+= and -= aren't unary operators though, they are a special case of assignment operators (and Lua as used in Löve only has
the assignment operator '=' (singular).
Assignment operators look like infix operators but they actually aren't since
a) they don't form an expression / yield a value (can't do
print(a = 3) is illegal)
b) the left hand side can't be any expression, it must be a variable (can't do
3 = 3)