Okay, so your arrayOf() function could be written as: auto arrayOf(T x, uint n){ return repeat([x], n); } Only needs to wrap the argument inside another array literal.