Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I have problems using the unpack() function, could someone help me out?

Asked by 5 years ago
Edited 5 years ago
lol = {"a", "b"}

if unpack(lol) == "a b" then
    print("yep")
end

It never prints "yep", what is the reason behind that?

0
my dude. just unpack into a table then compare via an in-depth function Fifkee 2017 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

You don't understand Tuples

You can't compare tuples, much less like that. I highly suggest you go read up on how Tuples work.

Ad
Log in to vote
0
Answered by 5 years ago
 t = {"a","b"}

if unpack(t) == "a" and "b" then
    print('yep')
    end

"a b" would be considered as one element. thats the problem

0
wrong User#6546 35 — 5y
0
works fine for me. i don't know why you downvoted Theswagger66 54 — 5y
0
I downvoted because it's wrong. Try it with t = {'a', 'b'} but don't change your condition User#6546 35 — 5y
0
It will (incorrectly) print 'yep' User#6546 35 — 5y
0
I wrote t={'a','b'} by accident but I meant t={'a', 'c'} User#6546 35 — 5y

Answer this question