# Inferring the type of an operation for \`struct\` fields

**URL:** <https://discourse.julialang.org/t/inferring-the-type-of-an-operation-for-struct-fields/32694>\
**Category:** General Usage\
**Created:** [December 25, 2019, 2:04pm UTC](https://discourse.julialang.org/t/inferring-the-type-of-an-operation-for-struct-fields/32694 "2019-12-25T14:04:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![OvidiusCicero](https://avatars.discourse-cdn.com/v4/letter/o/73ab20/32.png) [@OvidiusCicero](https://discourse.julialang.org/u/OvidiusCicero)\
**Post date:** [December 25, 2019, 2:04pm UTC](https://discourse.julialang.org/t/inferring-the-type-of-an-operation-for-struct-fields/32694/1 "2019-12-25T14:04:00Z")

</div>

I have a struct

```julia
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

```julia
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`

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [December 25, 2019, 2:32pm UTC](https://discourse.julialang.org/t/inferring-the-type-of-an-operation-for-struct-fields/32694/2 "2019-12-25T14:32:45Z")

</div>

Parameterize that field as well?

---

<div class="post-metadata">

**Author:** ![OvidiusCicero](https://avatars.discourse-cdn.com/v4/letter/o/73ab20/32.png) [@OvidiusCicero](https://discourse.julialang.org/u/OvidiusCicero)\
**Post date:** [December 25, 2019, 2:33pm UTC](https://discourse.julialang.org/t/inferring-the-type-of-an-operation-for-struct-fields/32694/3 "2019-12-25T14:33:52Z")

</div>

yes

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

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [December 25, 2019, 3:15pm UTC](https://discourse.julialang.org/t/inferring-the-type-of-an-operation-for-struct-fields/32694/4 "2019-12-25T15:15:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![OvidiusCicero](https://avatars.discourse-cdn.com/v4/letter/o/73ab20/32.png) [@OvidiusCicero](https://discourse.julialang.org/u/OvidiusCicero)\
**Post date:** [December 25, 2019, 3:26pm UTC](https://discourse.julialang.org/t/inferring-the-type-of-an-operation-for-struct-fields/32694/5 "2019-12-25T15:26:01Z")

</div>

okay, thanks anyway
