title: Lose some if/else if statments! What should I use to replace them ? - SWIFT -
body: <p>I'm making a unit convertor, I'm using an array like this :</p>
  
  <pre><code>private var subContentArray = [["Millimeter", "Centimeter", "Meter",    "Kilometer", "Foot", "Yard", "Mile"],
  ["Milliliter", "Centiliter", "Liter", "Gallon", "Quart", "Pint", "Fluid ounce"],
  ["Milligram", "Centigram", "Gram", "Kilogram", "Stone", "Pound", "Ounce"]]
  </code></pre>
  
  <p>And I'm using a picker that is set with 3 piker fields : </p>
  
  <pre><code>func pickerView(pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int)  {
  
      if pickerView.tag == 0  {
          currentSelection = row
          self.pickerGeneral.text = self.pickerGeneral1[row]
          self.view.endEditing(true)
      } else if pickerView.tag == 1 {
          self.pickerTextField.text = self.pickerSubContent[currentSelection][row]
          self.view.endEditing(true)
      } else if pickerView.tag == 2 {
          self.pickedTextField2.text = self.pickerSubContent[currentSelection][row]
          self.view.endEditing(true)
      }
  }
  </code></pre>
  
  <p>I wanna change the 2nd and 3rd picker by the General picker. So far everything is good, but then I wanna make the calculations and I was trying to do something like this : </p>
  
  <pre><code>func updateOutput(){
      //var res: Double
      var result: Double
      if input.text!.isEmpty {
          return
  
      } else if pickerTextField.text! == "Centimeter" &amp;&amp; pickedTextField2.text == "Mile" {
              result = (Double(self.input.text!)! / 160934.4)
              self.output.text! = String("\(result)")
  
      } else if pickerTextField.text! == "Mile" &amp;&amp; pickedTextField2.text! == "Centimeter" {
              result = (Double(self.input.text!)! * 160934.4)
              self.output.text! = String("\(result)")
  
      } else if pickerTextField.text! == "Centimeter" &amp;&amp; pickedTextField2.text == "Millimeter" {
              result = (Double(self.input.text!)! * 10)
              self.output.text! = String("\(result)")
  
      } else if pickerTextField.text! == "Millimeter" &amp;&amp; pickedTextField2.text! == "Centimeter" {
              result = (Double(self.input.text!)! / 10)
              self.output.text! = String("\(result)")
  
      }
  </code></pre>
  
  <p>...until I realize that if I'm gonna keep writing if/else if...i won't end soon and it will look really messy!</p>
  
  <p>I'm still a noob in to OOP and this branch but willing to learn...so, any help, with example and explains will be very well appreciated!!!!</p>