title: Detecting if a variable can be printed in Lua
body: <p>I've got a variable that could be a number of types - sometimes it's a string, sometimes a number, table or bool. I'm trying to print out the value of the variable each time like this:</p>
  
  <pre><code>print("v: "..v)
  </code></pre>
  
  <p>with <code>v</code> being my variable. Problem is, when I get a value that can't be concatenated I get this error:</p>
  
  <blockquote>
    <p>myscript.lua:79: attempt to concatenate a table value</p>
  </blockquote>
  
  <p>I've tried changing it to this in case it manages to detect whether or not the variable can be printed:</p>
  
  <pre><code>print("v: "..(v or "&lt;can't be printed&gt;"))
  </code></pre>
  
  <p>but I had the same problem there. Is there some sort of function I can use to determine if a variable can be concatenated to a string, or a better way of printing out variables?</p>