I recall seeing something like this a few years ago…
local var = "I love %xyz soup"
print(var("Chicken"))
I love Chicken soup
Is this possible and if so how exactly do you do it?
I know I can achieve the same with typical functions, I’m just curious to see if this can be done. 
For example, this produces the same result, it just looks a bit messy:
local var = function(v) return "I love "..v.." soup" end
print(var("Chicken"))
Isn’t this just string manipulation? The first one wouldn’t be possible because you’re attempting to call a string variable as a function - the second one is fine.
On that topic, let me throw in a third function in just for kicks.
local var = function(text)
return string.format("I love %s soup", tostring(text))
end
print(var("chicken"))
3 Likes
Perfect, just had a look at the wiki and that’s the one! Thank you.
``
local var = "I love %s soup"
print(string.format(var, "Chicken"))
I love Chicken soup
1 Like