Hey guys, I was going through someones code, and I found this line of code. I've never used the format method, so, what would this sequence of code do?
w.Name = ("%s_Weld"):format(v.Name)
?
It uses string patterns to substitute in text or anything that tostrings() to text passed to the format method as arguments to make a complete string.
It's an alternate to concatenation, basically, and is sometimes easier to read and smaller to write.
It's an alternative to concatenation, and in some cases, is easier to read. For example:
local myString = "Hello, my name is %s." print(myString:format("David")) --'David' is substituted for the %s pattern --OUTPUT: Hello, my name is David.