of     1   

Duncan2468
#183604164Sunday, February 14, 2016 6:56 PM GMT

The difference between pairs and ipairs is that: ipairs work on arrays, while pairs work on arrays and dictionaries. ipairs stop on the first nil value, while pairs keep going. Is that it?
cheesecake123456
#183604841Sunday, February 14, 2016 7:03 PM GMT

They both work on arrays, tables and dictionaries. The only difference is ipairs stops at the first nil value.
Duncan2468
#183605208Sunday, February 14, 2016 7:08 PM GMT

Wait, really? I was told ipairs only work on arrays. Anyways, why is ipairs useful if it stops at a nil value? Doesn't that encourage people to use pairs instead?
cheesecake123456
#183605400Sunday, February 14, 2016 7:10 PM GMT

Perhaps if you have a table with uncertain values that you generated dynamically, it would be a failsafe to use ipairs.
JarodOfOrbiter
#183605411Sunday, February 14, 2016 7:11 PM GMT

ipairs only works on arrays, you were correct.
JarodOfOrbiter
#183605582Sunday, February 14, 2016 7:13 PM GMT

No, Cheesecake, it's like doing this #code local Dictionary = { Value1 = 7, Value2 = 5, Value99 = -2.5 } for Index = 1, #Dictionary do print(Dictionary[Index]) -- Dictionary[1], Dict[2], and Dict[3] don't exist. That's kind of why ipairs won't work. -- Of course, #Dictionary is 0, so it won't work anyways. end
Duncan2468
#183605878Sunday, February 14, 2016 7:18 PM GMT

also: function connectAll(tbl, event, func, cond) cond = cond or true for i,child in pairs(tbl) do local s, m = pcall(function() if cond then child[event]:connect(func) end end) end end When I call pcall, will it only work on the children that have the specific event?
JarodOfOrbiter
#183605895Sunday, February 14, 2016 7:18 PM GMT

Most table functions only work with arrays. (Tables with positive integral keys greater than 0) table.remove, table.insert, ipairs, #Table, table.sort, and so forth only work on arrays, up to the first nil value. That's just how Lua tables work. Dictionaries have no order, so you can't sort them. Getting the length is the only thing here that would actually be useful for dictionaries, but oh well.
JarodOfOrbiter
#183605983Sunday, February 14, 2016 7:20 PM GMT

Yeah, it will only work on the specific event.

    of     1