Jump to content

Some questions


Hero192

Recommended Posts

You can use break to break a loop.

for i=1, 10 do 
    if i == 5 then 
        break -- Breaks loop, doesn't go on. 
    end 
end 

While is like a loop which repeats process until the condition is true.

while true do 
end 
  
-- Or: 
local i = 1 
while i <= 10 do 
    i = i + 1 -- Goes until 10 
end 

Until is used with repeat like:

  
local i = 1 
  
repeat -- Repeats step until desired value or true 
    i = i + 1 
    until i == 10 -- Stops when it's 10 

Link to comment

Ipairs goes thru table containing number indexes in the row. Any other would be skipped. If your table is indexed number by number you should use ipairs. But if table contains number indexes 1,2,3,4,6 ipairs will stop at 4, then you must use pairs which is lil bit slower.

Link to comment

From my point of view:

Pairs gives a general iterator over all the keys and values in the table, numerical or not, in no particular order, meanwhile ipairs goes over the array part, in order. Therefore pairs is faster.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...