Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. mapping(address => MyStruct[]) public structs;
  2.  
  3. structs[_user].length = 0; // will trigger an error !
  4.  
  5. function _burn(uint index) internal {
  6.  
  7. require(index < array.length);
  8.  
  9. array[index] = array[array.length-1];
  10. delete array[array.length-1];
  11.  
  12. // when array.length is set to 0 it doesn't work:
  13.  
  14. array.length = array.length - 1; // doesn't work if array.length = 1
  15.  
  16. array.length = 0; // doesn't work
  17.  
  18. // when array.length is set to a value > 0 it works:
  19.  
  20. array.length = 1; // works
  21.  
  22. array.length = 2; // works
  23.  
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement