title: Julia : Make method take array as parameter
body: <p>I'm currently programming in Julia and I want a method (The constructor of class ProbData) to take an array of a defined type as its parameter. What I'm currently doing is:</p>
  
  <pre><code>function ProbData(variables::AbstractArray{BaseVariable, 1})
      instance = new()
  
      instance.numPara = size(variables, 1)
      instance.numRand = 0
  
      for x = variables
          if x.variableType != "Det"
              instance.numRand += 1
          end
      end
  
      instance.getNumPara = function()
          return instance.numPara
      end
  
      instance.getNumRand = function()
          return instance.numRand
      end
  
      return instance
  end
  </code></pre>
  
  <p>BaseVariable is an abstract that has three subtypes. When I try to:</p>
  
  <pre><code>x = DetVariable("test", 0.15)
  P = ProbData([x])
  </code></pre>
  
  <p>I get this error message:</p>
  
  <pre><code>ERROR: LoadError: MethodError: 'convert' has no method matching convert(::Type{ProbData}, ::Array{DetVariable.jl,1})
  </code></pre>
  
  <p>How can I fix this? I've just learned this language for a few days, so if you can point out what I shouldn't have done, I would appreciate it as well.</p>
  
  <p>Edit: I've found out that if I defined the parameter array of the constructor to be an array of a certain type rather than an array of an abstract, the code would work properly. However, I need the parameter to be an array, whose elements could be of any subtype of BaseVariable.</p>