For some reason solidity doesn't allow to push values into memory array

> Member "push" is not available in bytes32[] memory outside of
> storage.

Here is sample contract code:

    pragma solidity ^0.4.21;
    
    contract Foo {
        function getRange(uint n) public pure returns(uint[]) {
            uint[] memory result;
            for (uint i = 0; i < n; i++)
                result.push(i);
            return result;
        }
    }


How could it be done?


  [1]: https://github.com/ethereum/dapp-bin/blob/master/library/stringUtils.sol