title: Multiple dispatch for methods of a class in Julia
body: <p>My question is how can I overload certain method <strong>within</strong> a certain class in Julia?</p>
  
  <p>In other words suppose I have a following definition of a class:</p>
  
  <pre><code>type Sometype
      prop::String
  
      setValue::Function
  
      # constructor
      function Sometype()
          this = new ()
  
          this.prop = ""
  
  ####### v1 #######
          this.setValue = function(v::Real)
              println("Scalar Version was Invoked!")
              # operations on scalar...
              # ...
          end
  
  ####### v2 #######
          this.setValue = function(v::Vector{Real})
              println("Vector Version was Invoked!")
              # operations on vector...
              # ...
          end
  
  ####### v3 #######
          this.setValue = function(v::Matrix{Real})
              println("Matrix Version was Invoked!")
              # operations on Matrix...
              # ...
          end
  
          return this
      end
  end
  </code></pre>
  
  <p>So when I say in my main code:</p>
  
  <pre><code>st = Sometype()
  st.setValue(val)
  </code></pre>
  
  <p>depending on whether <code>val</code> is a <strong>scalar</strong>, <strong>vector</strong> or <strong>matrix</strong> it would invoke the corresponding version of a <code>setvalue</code> method. Right now, with definition above, it overrides definitions of <code>setvalue</code> with the last one (matrix version in this case).</p>