Advertisement
Guest User

Untitled

a guest
Jun 28th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. local tab = {
  2. ['A'] = {Number = 1}
  3. }
  4.  
  5. --Standard way to remove a value from a table
  6.  
  7. for i,v in next, tab do
  8. if i == 'A' then
  9. table.remove(tab,i) --Except here, i is a string, not a number
  10. end
  11. end
  12.  
  13. -- If I try to do
  14.  
  15. tab['A'] = nil
  16.  
  17. --this wont work because of the fact that
  18.  
  19. ' for i,v in next, ' doesnt like nil values in tables.
  20.  
  21. What is the workaround for removing a key that is a string from a table?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement