|
| 06 Dec 2016 09:39 PM |
Is it bad to write stuff like this?
local x=("y"):byte() x=x%2==1 and x-1 or x print(x)
instead of
local x=("y"):byte() if x%2==1 then x=x-1 end print(x)
I have only ever seen one other person use the first one.
|
|
|
| Report Abuse |
|
|
|
| 06 Dec 2016 09:42 PM |
| I used to do it a lot. I think it makes the code a bit harder to read. |
|
|
| Report Abuse |
|
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 06 Dec 2016 09:54 PM |
Yeah typically it makes it harder to read. Doing something like:
optParam = optParam or defaultValue is fine IMO though |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 06 Dec 2016 09:59 PM |
it makes the code easier to write
|
|
|
| Report Abuse |
|
|
Kodran
|
  |
| Joined: 15 Aug 2013 |
| Total Posts: 5330 |
|
| |
|
| |
|