Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How have a string perform like Java?

Asked by 4 years ago

In Java you can have:

String name = "myNameis";
String myString = name + "myName";

How do have the plus sign (demonstrated above) in Lua

0
Do myString = name.."myName" Spjureeedd 385 — 4y
0
Thanks, that works awesomemode14 68 — 4y
0
No problem Spjureeedd 385 — 4y

1 answer

Log in to vote
2
Answered by 4 years ago
Edited 4 years ago

The concatenation operator in Lua is .., unlike other languages such as Java, Python, etc.

So it would be name .. "myName".

If you really want to use +, you can overload the + operator to do so.

tfw Java has no operator overloading
getmetatable("").__add = function(a, b)
    return a .. b
end

This will NOT work on Roblox.

Ad

Answer this question