How to resolve - Value toDF is not a member of org.apache.spark.rdd.RDD

How to resolve - Value toDF is not a member of org.apache.spark.rdd.RDD

Hi guys, i just started learning Spark with scala and like many starters your get to encountered configuration issues and other smaller issues. I ran into the error "Value toDF is not a member of org.apache.spark.rdd.RDD" when i was trying to create a Dataframe in spark. 

After doing some research online, i discover many developers had similar problems so i continue to dig deeper in search for a way around. 
On faithful morning i stumble on a simple fixed which i will describe below: 

Step: 

1) Get  sqlContext as below.

val sqlContext = new org.apache.spark.sql.SQLContext(sc)
import sqlContext.implicits._

2) case class need to be out of method. This is also mentioned in most of the blogs, so i was wondering how to then i remembered my simple coding standards as below:

object Foo {
  case class Summary(ismatch: Double, t_to_last:Double, nflips:Double,d_uid: Double, truth:Double, guess:Double)
  def main(args: Array[String]){
    ...
  }
}

Implementing these steps resolve the issue.

Hi guys share to help other developers.