# Can anyone help me on understanding this code from lecture 67 of CCA 175? Thx

#1

Original data:

scala> orders.take(10).foreach(println)
1,2013-07-25 00:00:00.0,11599,CLOSED
2,2013-07-25 00:00:00.0,256,PENDING_PAYMENT
3,2013-07-25 00:00:00.0,12111,COMPLETE
4,2013-07-25 00:00:00.0,8827,CLOSED
5,2013-07-25 00:00:00.0,11318,COMPLETE
6,2013-07-25 00:00:00.0,7130,COMPLETE
7,2013-07-25 00:00:00.0,4530,COMPLETE
8,2013-07-25 00:00:00.0,2911,PROCESSING
9,2013-07-25 00:00:00.0,5657,PENDING_PAYMENT
10,2013-07-25 00:00:00.0,5648,PENDING_PAYMENT

Transformed it into a paired RDD as below:

val ordersPairedRDD = orders.map(order=>{
val o = order.split(",")
(o(0).toInt, o(1).substring(0,10).replace("-","").toInt)
})

scala> ordersPairedRDD.take(10).foreach(println)
(1,20130725)
(2,20130725)
(3,20130725)
(4,20130725)
(5,20130725)
(6,20130725)
(7,20130725)
(8,20130725)
(9,20130725)
(10,20130725)

What I don’t understand is the definition of val o:
val o = order.split(",")
(o(0).toInt, o(1).substring(0,10).replace("-","").toInt)

In an attempting to understand it, I tried the following scripts:

val firstOrder = orders.first
val one = firstOrder.split(",")(one(0).toInt, one(1).substring(0, 10).replace("-", “”).toInt)

Note val one has the same definition of o

This throws out the following error to me:

:31: error: recursive value one needs type
val one = firstOrder.split(",")(one(0).toInt, one(1).substring(0, 10).replace("-", “”).toInt)

Thank you.