Forum Discussion
Komag
11 years agoRoku Guru
"EnTerr" wrote:
Personally i recommend doing the type check with `getInterface(val, "ifString") <> invalid` instead. It's shorter and faster (just ran some tests - at least 2x faster in general, can be 7x faster if type(val)="roString" in particular).
Best however will be to define a test function for that and use it. That way code is most readable and fn can be updated in the future (or switch between the three different approaches in this thread). Here is mine:function isString(val):
return getInterface(val, "ifString") <> invalid
end function
But would calling the function lose some of the snappiness? I mean if this is done many times per second, wouldn't it be faster to keep it direct, just use `getInterface(val, "ifString") <> invalid`? I have a LOT of functions, and I'm beginning to wonder if the game has to do a big search through all the functions to find the one with the right name and whether that takes time, sort of like looking up a key/value pair in an AA with . operator.
EDIT - This will work to check that it's either a String or a roString?