Difference between string.format() and :format()

Hey there, I was just wondering what the difference was between the two in this post’s title.
I personally use string.format() but my friend uses :format(). They both output the same result.

print(string.format("%s", "hi"))

or

print(("%s"):format("hi"))

Which is better and why?

It’s the same thing. Format is just a metamethod of the string, both work just fine.

2 Likes

The method the Developer Hub tends to favor is string.format(), but there doesn’t seem to be any difference with string.format and string:format. You can use both interchangeably.

2 Likes