View Single Post
02-01-09, 04:26 AM   #609
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
Originally Posted by grimman View Post
I'm really miffed by this. I see lots of people using select() to do various stuff, lua.org has a bunch of examples using select() and Slouken shows up more than once on google giving examples... but I just can't use it.
Code:
function dummyfunction()
print(select(2, UnitClass("player")))
end
That code throws an error (something to do with select, I don't remember the exact wording).
That doesn't throw an error.
Originally Posted by grimman View Post
Using it with /script print(select(1, UnitClass("player"))) just gives me "Paladin PALADIN", which isn't even the expected output (though the class is obviously right). wth am I doing wrong?
And that's not the expected behavior. It behaves correctly, you select the first return and all after.
Originally Posted by grimman View Post
I only tried this stuff because I was curious about your statement, haste. For the record, I can do local _,class=UnitClass("player") ~1m times per second. Even if select() was twice as slow/fast/whatever (and worked!) it wouldn't be likely to impact anything unless the coder is an outright idiot.
Many small steps make a leap. It was really just meant as a minor tips on what you should avoid doing.

Then again using select() can avoid some odd cases like local _ b = UnitClass'player' and such.