title: Access in array in specific indices
body: <p>I am trying to access an array in a function, as far as I understand there is no Arraylists in Swift, so I am trying to use regular list:</p>
  
  <pre><code>  func findNearsetPoints(pointsArray: [Point] , myPoint: Point )-&gt; Array &lt;Point&gt;{
  
      var twoPoint = [Point]()
      var minDist1:Double = DBL_MAX;
      var minDist2:Double = DBL_MAX;
      var distance:Double = 0
  
      for element in pointsArray{
          distance = getDistanceBetweenTwoPoints(pointsArray[element], Point); //error 0
          if (distance &lt; minDist1) {
              minDist1 = distance;
              twoPoint[1] = twoPoint[0];
              twoPoint[0] = pointsArray[element]; // error 1
          }
          else if (distance &lt; minDist2) {
              minDist2 = distance;
              twoPoint[1] = pointsArray[element]; //error 1
          }
      }
  
      return twoPoint;
      }
  
      func getDistanceBetweenTwoPoints(point1:Point , point2:Point )-&gt;Double{
          return 5; //TODO
      }
  </code></pre>
  
  <p>error 0: </p>
  
  <blockquote>
    <p>/Users/user/Desktop/proj/ViewController.swift:145:38: Cannot subscript a value of type '[ViewController.Point]' with an index of type 'ViewController.Point'</p>
  </blockquote>
  
  <p>error 1:</p>
  
  <blockquote>
    <p>/Users/user/Desktop/proj/ViewController.swift:149:38: Cannot subscript a value of type '[ViewController.Point]' with an index of type 'ViewController.Point'</p>
  </blockquote>
  
  <p>What is wrong with the code?
  thanks!</p>