title: Only safe or non null assserted calls are allowed on a nullable receiver type of arraylist
body: <p>Just started using kotlin for android development.My arraylist is declared like this-</p>
  
  <pre><code>var day1: ArrayList&lt;DietPlanDetailModel&gt;? = null
  </code></pre>
  
  <p>Now I am trying to access an element by its position</p>
  
  <pre><code>    val dietPlan= day1[position]
  </code></pre>
  
  <p>but i am getting below compile time error-</p>
  
  <blockquote>
    <p>Only safe or non null assserted calls are allowed  on a nullable
    receiver type of arraylist</p>
  </blockquote>
  
  <p>Why am i getting this error and how can i resolve it?</p>