local Mystery = {}
local function PrintWhatType1(X)
if type(X) == 'number' then
print('number')
elseif type(X) == 'table' then
print('Table')
elseif type(X) == 'string' then
print('String')
end
end
local function PrintWhatType2(X)
if type(X) == 'number' then
print('number')
end
if type(X) == 'table' then
print('table')
end
if type(X) == 'string' then
print('String')
end
end
What is the difference and what function is more efficient to do?
PrintWhatType1(Mystery)
PrintWhatType2(Mystery)

4 comments
The two do the same thing, but I think there's no difference between them. I would say "elseif", because it's less writing.
such performance differences, if they existed, would fall into the category of micro optimizations, as the time it takes to swap from one to the other is more than the performance boost you actually get from the optimization over thousands of users.
there is a spacial benefit to using the former however, as the latter incorporates an extra newline character. however, looking at it from the perspective of raw character count , if including the newline characters, the difference is that the latter is one character shorter than the former
Elseif is shorter and more efficient and simpler. By the way, use typeof instead of type.