title: how to determine class of an object
body: <p>Note- The related question does not explain why <code>attr(myVar, "class")</code> returns <code>NULL</code> but not <code>list</code> (and why <code>class(myVar)</code> returns <code>list</code>).  What is the stander way in R to check the class of an object?</p>
  
  <p>How do I find out if an object is "my custom class" or is a "list" of "my custom class" objects?</p>
  
  <pre><code>foo &lt;- function(x) {
    a=list(x=x)
    attr(a, "class") &lt;- "myclass"
    return(a)
  }
  
  newVar = list(foo(10),foo(20))
  </code></pre>
  
  <p>Now I want to find out what class of <code>newVar</code> .</p>
  
  <pre><code>attr(newVar, "class")  # NULL, but not list!
  #NULL
  
  ##however this works fine
  attr(newVar[[1]], "class")
  #[1] "myclass"
  </code></pre>
  
  <p>Why is it so? What is the <strong>correct</strong> way to determine class in R?</p>