title: How to call parametric constructor appropriately in Julia?
body: <p>I wanted to call the constructor of composite type <code>WeightedPool1D</code> but I tried both <code>WeightedPool1D(mask)</code> and <code>WeightedPool1D{Float64}(mask)</code> but it did not work.</p>
  <p>Thanks!</p>
  <p>Julia version: 1.6.1</p>
  <p>My code:</p>
  <pre><code># creating composite type
  struct WeightedPool1D{T}
      n::Int
      c::Int
      mask::Matrix{Bool}
      weight::Matrix{T}
      function WeightedPool1D(mask::Matrix{Bool}) where T
          c, n = size(mask)
          weight = randn(T, c, n) / n
          new{T}(n, c, mask, weight)
      end
  end
  
  # create argument
  mask = zeros(Bool, 3, 3)
  </code></pre>
  <p>Calling <code>w = WeightedPool1D(mask)</code> gives the error</p>
  <pre><code>julia&gt; w = WeightedPool1D(mask)
  ERROR: UndefVarError: T not defined
  </code></pre>
  <p>Calling <code>w = WeightedPool1D{Float64}(mask)</code> gives the error</p>
  <pre><code>julia&gt; w = WeightedPool1D{Float64}(mask)
  ERROR: MethodError: no method matching WeightedPool1D{Float64}(::Matrix{Bool})
  </code></pre>