title: How to encounter with error-"InvalidOperationException: Operation is not valid due to the current state of the object" upon use of System.Linq
body: <pre><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  using System.Linq;
  
  public class qtpye : MonoBehaviour {
      public LineRenderer lr;
      public EdgeCollider2D ec;
      public List&lt;Vector3&gt; points;
      private bool jok=true;
      // Use this for initialization
      void Start () {
  
      }
  
      // Update is called once per frame
      void Update () {
          if (jok ==false&amp;Vector3.Distance(points.Last(),transform.position)&gt;0.7f)
              {
              points.Add (transform.position);
              lr.positionCount = points.Count;
              lr.SetPosition (points.Count - 1, new Vector3 (Camera.main.ScreenToWorldPoint (Input.mousePosition).x, Camera.main.ScreenToWorldPoint (Input.mousePosition).y, transform.position.z));
          }
  
  
  
      }
      void OnMouseDown()
      {jok = false;
          Debug.Log ("f");
      }
      void OnMouseUp()
      {jok = true;
  
      }
  
  }
  </code></pre>
  
  <p>I am trying to use line renderer however error comes up for<br>
  <code>if (jok ==false&amp;Vector3.Distance(points.Last(),transform.position)&gt;0.7f)</code> 
  which is </p>
  
  <blockquote>
    <p>InvalidOperationException: Operation is not valid due to the current
    state of the object System.Linq.Enumerable.Last[Vector3]
    (IEnumerable`1 source) qtpye.Update () (at Assets/qtpye.cs:18)</p>
  </blockquote>