# Struct in my package cannot be called correctly

**URL:** <https://discourse.julialang.org/t/struct-in-my-package-cannot-be-called-correctly/90145>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [November 12, 2022, 2:36am UTC](https://discourse.julialang.org/t/struct-in-my-package-cannot-be-called-correctly/90145 "2022-11-12T02:36:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![XuJingye2022](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xujingye2022/32/38972_2.png) [@XuJingye2022](https://discourse.julialang.org/u/XuJingye2022)\
**Post date:** [November 12, 2022, 2:36am UTC](https://discourse.julialang.org/t/struct-in-my-package-cannot-be-called-correctly/90145/1 "2022-11-12T02:36:58Z")

</div>

My package structure:

```julia
module DoubleRFs

export ParDBRF

struct ParDBRF # params of double rf
    # ===== To be prepared =====
    v1::Float64
    r::Float64
    ϕs::Float64
    ϕ2s::Float64
    h1::Int64
    h::Int64
    circum::Float64
    centerenergy::Float64
    αc::Float64
    ξ::Float64
    νy::Float64
    σδ::Float64
    # ===== Calculated automatically ======
    ωβ::Float64
    ω0::Float64
    ωξ::Float64
    γ::Float64
    η::Float64
    # ===== inner constructor ======
    Param(v1, r, ϕs, ϕ2s, h1, h, circum, centerenergy, αc, ξ, νy, σδ)=new(v1, r, ϕs, ϕ2s, h1, h, circum, centerenergy, αc, ξ, νy, σδ, νy*2*π*299792458.0/circum, 2*π*299792458.0/circum, νy*2*π*299792458.0/circum*ξ/(αc-1/(centerenergy/0.511e6)^2), centerenergy/0.511e6, αc-1/(centerenergy/0.511e6)^2)
end
Base.broadcastable(x::ParDBRF) = Ref(x)

end

```

When I called this struct, an error was reported:

```julia
> param=DoubleRFs.ParDBRF(3639505.370587, 0.1833, 2.0399026, 5.708, 756, 3, 1360.4, 6e9, 0.0000156073, 0.0, 106.27, 1.06e-3)
MethodError: no method matching DoubleRFs.ParDBRF(::Float64, ::Float64, ::Float64, ::Float64, ::Int64, ::Int64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64)

Stacktrace:
 [1] top-level scope
   @ In[3]:1
 [2] eval
   @ .\boot.jl:360 [inlined]
 [3] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
   @ Base .\loading.jl:1116

```

---

<div class="post-metadata">

**Author:** ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)\
**Post date:** [November 12, 2022, 3:32am UTC](https://discourse.julialang.org/t/struct-in-my-package-cannot-be-called-correctly/90145/2 "2022-11-12T03:32:59Z")

</div>

> [@XuJingye2022](#):
>
> ```julia
> # ===== inner constructor ======
> Param(v1, r, ϕs, ϕ2s, h1, h, 
> 
> ```

You have defined a function as an inner constructor, removing the default constructors. Note that you’ve used a different name for that than the name of the struct.

---

<div class="post-metadata">

**Author:** ![XuJingye2022](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xujingye2022/32/38972_2.png) [@XuJingye2022](https://discourse.julialang.org/u/XuJingye2022)\
**Post date:** [November 12, 2022, 3:40am UTC](https://discourse.julialang.org/t/struct-in-my-package-cannot-be-called-correctly/90145/3 "2022-11-12T03:40:00Z")

</div>

Thanks, but inner constructor is really convenient. If I remove this constructor, is there an alternative?

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [November 12, 2022, 3:59am UTC](https://discourse.julialang.org/t/struct-in-my-package-cannot-be-called-correctly/90145/4 "2022-11-12T03:59:38Z")

</div>

use an outer constructor

---

<div class="post-metadata">

**Author:** ![XuJingye2022](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xujingye2022/32/38972_2.png) [@XuJingye2022](https://discourse.julialang.org/u/XuJingye2022)\
**Post date:** [November 12, 2022, 4:10am UTC](https://discourse.julialang.org/t/struct-in-my-package-cannot-be-called-correctly/90145/5 "2022-11-12T04:10:26Z")

</div>

Thank you.
