Login to WatchAwear

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

Download the 'WatchAwear - Companion for WatchMaker' App
WatchAwear - Companion for WatchMaker

Download The Best Watch Designing App
for Wear OS, and Tizen:

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)