View Single Post
09-19-16, 05:44 AM   #9
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
Originally Posted by myrroddin View Post
Always nice to see tutorial code, but gah, guys! Where are the spaces? Let it breathe, as it adds readability. I know it is user preference, but really!
Lua Code:
  1. local tostring=tostring -- ouch on the brain and eyes
  2. local tostring = tostring -- ah, much better
  3.  
  4. -- which of these looks better?
  5. for i=1,select("#",...) do msg=(msg~="" and msg.." " or "")..tostring(select(i,...)); end
  6.  
  7. for i = 1, select("#", ...) do msg = (msg ~= "" and msg .." " or "") .. tostring(select(i, ...)); end
  8.  
  9. for i = 1, select("#", ...) do
  10.     msg = (msg ~= "" and msg .." " or "") ..tostring(select(i ,...));
  11. end
It's personal preference. This looks better to me:

Lua Code:
  1. for i=1,select('#',...) do
  2.     msg=(msg~='' and msg..' ' or '')..tostring(select(i,...))
  3. end

I only use spaces when absolutely necessary, and sometimes I don't even use returns. I usually just put a block onto one line if it's shorter than ~100 characters, but it depends on how it looks around other code.

Also, I refuse to use semicolons and unless I'm expecting apostrophes, I'll use single quotes.

Last edited by Kanegasi : 09-19-16 at 09:34 AM.
  Reply With Quote