# Weird constructor error

**URL:** <https://discourse.julialang.org/t/weird-constructor-error/51502>\
**Category:** New to Julia\
**Created:** [December 9, 2020, 8:28am UTC](https://discourse.julialang.org/t/weird-constructor-error/51502 "2020-12-09T08:28:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![stefkuypers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefkuypers/32/19185_2.png) [@stefkuypers](https://discourse.julialang.org/u/stefkuypers)\
**Post date:** [December 9, 2020, 8:28am UTC](https://discourse.julialang.org/t/weird-constructor-error/51502/1 "2020-12-09T08:28:05Z")

</div>

Hi,

I’m getting an error when calling a constructor and I can’t figure out what’s wrong. It used to work but after fiddling with the code a bit (I honestly don’t know what I changed exactly anymore since I was experimenting) I now get the following error:

```julia
ProductBlueprint("P")
ERROR: MethodError: no method matching (::Main.Production.var"#ProductBlueprint#3#4")(::Dict{Blueprint,Int64}, ::Int64, ::Type{ProductBlueprint}, ::String, ::Restorable)
Closest candidates are:
  ProductBlueprint#3(::Dict{Blueprint,Int64}, ::Float64, ::Type{ProductBlueprint}, ::Any, ::Any) at /Users/stef/Programming/Julia Projects/loreco-abm/cockpit/production/entities.jl:31
Stacktrace:
 [1] ProductBlueprint(::String, ::Restorable) at /Users/stef/Programming/Julia Projects/loreco-abm/cockpit/production/entities.jl:31 (repeats 2 times)
 [2] top-level scope at none:1

```

The source code:

```julia
abstract type Blueprint end

struct ConsumableBlueprint <: Blueprint
    type_id::UUID
    name::String
    ConsumableBlueprint(name) = new(uuid4(), name)
end

struct ProductBlueprint <: Blueprint
    type_id::UUID
    name::String
    lifecycle::Restorable
    restore_res::Dict{Blueprint,Int64}
    restore::Float64
    ProductBlueprint(name,
        lifecycle = Restorable();
        restore_res::Dict{Blueprint,Int64} = Dict{Blueprint,Int64}(),
        restore::Float64 = 0) = new(uuid4(), name, lifecycle, restore_res, restore)
end

```

The Restorable() constructor works. So does the ConsumableBlueprint() constructor.

Thanks in advance,  
Stef

---

<div class="post-metadata">

**Author:** ![FPGro](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fpgro/32/20822_2.png) [@FPGro](https://discourse.julialang.org/u/FPGro)\
**Post date:** [December 9, 2020, 9:55am UTC](https://discourse.julialang.org/t/weird-constructor-error/51502/2 "2020-12-09T09:55:25Z")

</div>

> [@stefkuypers](#):
>
> `restore::Float64 = 0`

`0` is of type `Int`, so the default value violates the type requirement. Just put a `.` after the number to indicate that it’s a Float 🙂 best of Luck!

---

<div class="post-metadata">

**Author:** ![stefkuypers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefkuypers/32/19185_2.png) [@stefkuypers](https://discourse.julialang.org/u/stefkuypers)\
**Post date:** [December 9, 2020, 10:11am UTC](https://discourse.julialang.org/t/weird-constructor-error/51502/4 "2020-12-09T10:11:30Z")

</div>

Thanks! I changed the input type of the constructor to Real and now it works.
