Anderl Posted February 21, 2013 Share Posted February 21, 2013 Yes, an iteration statement loops through all indexes in an array (you can call it array or table), 'i' and 'v' are the values from where the loop is (I just can't explain it better to you), you don't need to get the value of 'i' in the array again, simply use 'v' instead - that's what iteration statement vars are for, otherwise I'd use a while statement instead or anything else. Link to comment
csiguusz Posted February 21, 2013 Share Posted February 21, 2013 Yes i know this of course. I just did not understand what was your problem with my code. If i would use v instead, it wouldn't work well, but i've already explained this somewhere above. Link to comment
Anderl Posted February 21, 2013 Share Posted February 21, 2013 An easier way would be to instead of using table.remove, just set index's value to false. You would not need that much code this way. Link to comment
csiguusz Posted February 21, 2013 Share Posted February 21, 2013 He wanted to know how to remove them, so I found out how could he do it. Yes it sounds easier. My only problem with it is: the table would grow just bigger and bigger without removing unused values. But I don't think this really matters. Link to comment
Anderl Posted February 21, 2013 Share Posted February 21, 2013 He can later remove indexes with boolean value using table.remove, as long as he knows the max. of indexes in the array. Link to comment
csiguusz Posted February 21, 2013 Share Posted February 21, 2013 Then some more code is needed to delete the unused values of the table, so there would not be less code just easier code! Hehe... okay don't take this serious, that was just my first thought when I read your post Good night, thanks for the discussion. Link to comment
Anderl Posted February 21, 2013 Share Posted February 21, 2013 I don't think it would be needed to delete these indexes with nil value, so it is easier. Though, if it's for some reason needed, both ways would end up doing the same, yes. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now