I want to add a int to a number without additioning. For example: 123 + 3 = 3123, but I don't know how... Please help!
✓ ANSWER ACCEPTED
Add a int to a number without additioning?
1 answer
✓ Accepted answer
Without using addition, string concatenation should be performed. Concatenation is the act of the combination of multiple strings or numbers into one string. The symbol for concatenation is two periods (..).
So, in your case, to attach a number to another number without performing addition, you would make a string containing the original number and then concatenate the second number into the string (or concatenate both numbers respectively).
Option 1:
local new_number = 3
local new_string = new_number .. "123"
print(new_string)
The output:
3123
Option 2:
print(3 .. 123)
The output:
3123
Alternatively, if you had a table consisting of only numbers, you could use table.concat():
local number_table = {3, 123}
print(table.concat(number_table))
The output:
3123
So concatenation really is your best friend here.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Thank you so much. I was really not thinking enough.