Iteration uses a lot of gas. I was thinking at different options I could minimise the costs. I must understand why one thing doesn't work: Why can't I push into an array using multiplication rather than loops?
For example, this code works:
address[] contenders
for (int i; i<5;i++)
contenders.push(msg.sender);
This code doesn't:
address[] contenders
uint numberToMultiply /// let's say this variable is 5
contenders.push(msg.sender) * numberToMultiply
Basically in the last example I am expecting to push msg.sender in the array by the number of times stored in the variable.
Would it not be gas efficient? Furthermore, it doesn't work. Does anyone know the reason?