is it possible to do something along the lines of this
local da = "BA"
local ad = gsub
print(da:ad("B", ""))
is it possible to do something along the lines of this
local da = "BA"
local ad = gsub
print(da:ad("B", ""))
what’s your use case?
experimenting
i hate character limit
Yes, this is possible but it would just be string.gsub you don’t put the actual string there, the function takes the string in it!
local thing = string.gsub
print(thing("Hello world!", "world", "Earth"))
Would output Hello Earth!
Here’s the API ref for strings in case you are still confused
https://developer.roblox.com/en-us/api-reference/lua-docs/string
Thankyou for contribution but this isn’t what i was looking for, i was just asking if it is possible to do it some what way i posted. I guess not though
It’s not
("Hello"):gsub("ello", "ello World!")
What i want to do is have gsub as a variable so i can do
local a = gsub
("Hello"):a("ello", "ello World!")
This would just give a syntax error, and unfortunately won’t work.
Yes I know, that’s why I am asking if there is a way around it, but I’m guessing not
You can try ("Hello")[a]("Hello", "ello World!") but I don’t know if it will work.
You could do it with just
("Hello world"):gsub("world", "Earth!")
But you wouldn’t be able to set a variable for gsub
Alternatively, you could make an anonymous function and pass gsub through the function if you really wanted to do it in the same method as OP
You could also do string[a]("str1", "1", "2")