Inferring the type of an operation for `struct` fields

I have a struct

struct Test
    divisor::Int64
    dividend::Int64
    result::Float64
end
Test(divisor, dividend) = Test(divisor, dividend, divisor/dividend)

I want to make a template out of this struct such that instead Int64 the definition is like the following

struct Test2{T<:Integer}
…
end

but I don’t know what to do with result since in the optimal case for T being BigInt result should be of type BigFloat

EDIT:
the type of result should be parameterized depending on the concrete type T

Parameterize that field as well?

1 Like

yes

the type of result should be parameterized depending on the concrete type T

That cannot really be done. You would need to fix that in the constructor.

2 Likes

okay, thanks anyway