6
Vote

string.format Shorthand

Just a shorthand I found that can save you some keystrokes if you use string functions a lot, especially string.format. Instead of “string.format(“%s %d:%02d”, var_a, var_b, var_c)” for example, you can say:

(“%s %d:%02d”):format(var_a, var_b, var_c)

Note the syntax: the format string in quotes inside parens, then a colon, then “format”, and the parameters in parens. I don't actually know why the parens around the format string are necessary; I would not think they would be. I'm sure they aren't needed if the format is not a literal string (e.g. it's a variable).

Published by Mark Shoulson on 27 August 2015WatchMaker Tips & Tricks Posted

This Website and It's Resources are Powered by:
  
WatchMaker Beautiful Watches for Android Wear

No smartwatch required!! Best clock wallpaper for Android!
  
WatchMaker Live WallPaper

Introducing the Perfect Companion App for WatchMaker...
  
GearsPro (OBD 2 & Car)