Initialize an array with the type of a function return

Hello, I have the following setup: I want to initialize an array with a element-type which is given by a return type of a function. Something like this:

A = Array{typeof(f(1))}(undef, 10)
for 1 in 1:10 
   A[i] = f(i) 

This works but it calls the function f(1) explicitly. is there a good way to just get the return type without the need to call the function. In the real case the call is a time-heavy calculation.

I was able to use Base.return_types(f, (Int,))[1] but this seams to be a clumsy way, isn’t it?

There is some discussion here

For this specific example you would do [f(i) for i in 1:10]. Do you have another concrete example why you need to do this?

After asking this question I realized this possibility as well. No, for now I do not have a good idea why one could not use this array-syntax.

@Evizero: Thanks for linking to the article. It is good to know the general possibilities.

There’s some more discussion here: Ridiculous idea: types from the future in case you’re interested.