# Keyword argument constructor breaks Incomplete constructor

**URL:** <https://discourse.julialang.org/t/keyword-argument-constructor-breaks-incomplete-constructor/34198>\
**Category:** General Usage\
**Created:** [February 5, 2020, 5:35am UTC](https://discourse.julialang.org/t/keyword-argument-constructor-breaks-incomplete-constructor/34198 "2020-02-05T05:35:31Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![milesf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/milesf/32/9289_2.png) [@milesf](https://discourse.julialang.org/u/milesf)\
**Post date:** [February 5, 2020, 5:47am UTC](https://discourse.julialang.org/t/keyword-argument-constructor-breaks-incomplete-constructor/34198/2 "2020-02-05T05:47:08Z")

</div>

Interesting! It works if the keyword constructor is defined first:

```julia
julia> mutable struct Foo
           x::Float64
           y::Float64

           Foo(;x::Float64, y::Float64) = new(x, y)
           Foo() = new()
       end

julia> Foo()
Foo(6.94551569230195e-310, 0.0)

```

Looks like this gotcha was already reported here:

> [@Fun with kwargs methods](https://discourse.julialang.org/t/fun-with-kwargs-methods/15711/7):
>
> zerosM(dim; like::AbstractArray=Vector{Float64}()) = zeros(eltype(like), dim, dim) should do what you want.

---

_[View the full topic](https://discourse.julialang.org/t/keyword-argument-constructor-breaks-incomplete-constructor/34198)._
