4 ms·
Yes, strings are hashed at creation time. This means strings can never be modified => a new one is created. The down side is that string modification (includi
by daurnimator 13y ago
Yes, strings are hashed at creation time.
This means strings can never be modified => a new one is created.
The down side is that string modification (including appending) in a loop is expensive.
- russellsprouts 13y agoOf course, languages like Java have StringBuffer objects. In Lua, if you are generating a string, and you know that it will need a lot of concatenations, you can use something like this: local string_buffer = {} while condition() do table.insert(string_buffer, getString()) end local string = table.concat(string_buffer)