{"name":"resize","title":"resize","type":"command","url":"https://community.bistudio.com/wiki/resize","revid":364809,"updated":"2024-06-15T13:16:01Z","groups":["Arrays"],"status":"ok","games":{"ofp":"1.75","ofpe":"1.00","arma1":"1.00","arma2":"1.00","arma2oa":"1.50","tkoh":"1.00","arma3":"0.50"},"since":"ofp 1.75","arma3_since":"0.50","description":"Changes the size of the given array. The command does not return new array, it resizes the source array to the desired number of elements.\nIf the new size is bigger than the current size, the new places are filled with nil. The alternative syntax allows to fill resized positions with a given value. Array and HashMap values are copied.","syntaxes":[{"syntax":"array resize count","params":[{"name":"array","type":"Array of Anything","type_expr":"Array<Anything>"},{"name":"count","type":"Number","description":"the new array size","type_expr":"Number"}],"returns":{"type":"Nothing","type_expr":"Nothing"},"form":"binary","left":{"text":"array"},"right":{"text":"count"}},{"syntax":"array resize [count, fill]","since":"arma3 2.10","params":[{"name":"array","type":"Array of Anything","type_expr":"Array<Anything>"},{"name":"count","type":"Number","description":"the new array size","type_expr":"Number"},{"name":"fill","type":"Anything","description":"value to fill added positions","type_expr":"Anything"}],"returns":{"type":"Nothing","type_expr":"Nothing"},"form":"binary","left":{"text":"array"},"right":{"text":"[count, fill]"}}],"examples":[{"code":["_arrayNum = [0,1,2,3,4];\n_arrayNum resize 2; // _arrayNum is now [0, 1]\n_arrayNum resize 5; // _arrayNum is now [0, 1, nil, nil, nil]"]},{"code":["private _array = [0, 1, 2];\n_array resize [5, -1]; // _array is now [0, 1, 2, -1, -1]\n\nprivate _array = [0, 1, 2];\n_array resize [1, -1]; // _array is now [0]\n\nprivate _array = [0, 1, 2];\n_array resize [4, \"something\"]; // _array is now [0, 1, 2, \"something\"]"]}],"see_also":["set","reverse","deleteAt","deleteRange"],"notes":[{"user":"DreadedEntity","date":"2014-11-13T06:26:00Z","text":"Use this number to resize the array to the number of elements desired, not the desired index of the final element.\nresize cannot be used to create a new array."}]}