I know this is quite a long question, but to put it short, what is the difference between the find and match methods?
I hate stuff like this. When there are similar options, I can’t make my mind up without knowing the true difference. Please help and put my mind at ease, thank you!
Oh, and also, yes, I did do my research, but I didn’t understand what the people where talking about, in the places I looked.
My apologies, didn’t read your post content, only the title. So what I wrote doesn’t really make sense to the question you’re asking. I mean here if you want it:
There is small difference, the string library is just a library to manipulate strings, so even after putting a method after it, you would still have to pass the string as an argument:
local str = "Hello World!"
local Hello = string.find(str, "Hello")
print(Hello)-- Prints 1
local str2 = "Hello World!"
local Hello2 = str2.find(str2,"Hello")
print(Hello2) -- Prints 1
string.match() is a function call, while [string]:match() is a method call. Roblox has (or is going to) optimize function calling through a method called inline caching.
task.wait and wait are both from a global so this optimization doesn’t matter. Even though they’re both yielding functions, they actually have different behavior. task.wait() yields for the length of one frame, while wait() yields for 1/30th of a second.
Yeah you’re right, I just brought up string.find as it was probably the easiest one to make a code snippet out of. I just thought of functions like [string]:len().
I’m not sure what you’re trying to say, so now you’re saying [string]:match() is better, even though earlier on you said it was slower than using the string library one.
I know, I was saying like because task.wait() is a library, just like string.
Oh ok, I see, I suppose that actually makes a lot of sense, as doing [a piece of string]:match()/find() has to go through some stuff to then get to the library as well.
match and find are two different things. I was talking about using the : (colon) operator in relation to the . (dot) operator, which is what I thought you were confused about.