Strange behaviour of missing a DOT

@itversity or any guru
can tell me what does it mean this below

scala> val sample ="1,2013-07-25 00:00:00.0,11599,CLOSED"
sample: String = 1,2013-07-25 00:00:00.0,11599,CLOSED

scala> sample.split(",")(1).split(" ")
res15: Array[String] = Array(2013-07-25, 00:00:00.0)

scala> sample.split(",")(1).split(" ")(0).split("-").mkString("").toInt
res16: Int = 20130725

scala> sample.split(",")(1)split(" ")
res17: Array[String] = Array(2013-07-25, 00:00:00.0)

scala> sample.split(",")(1)split(" ")(0).split("-").mkString("").toInt
<console>:28: error: value split is not a member of Char
              sample.split(",")(1)split(" ")(0).split("-").mkString("").toInt
                                                ^

as you can see the missed dot works only on one case… #strange
I am curious if there is an explanation, but it’s not verey importnat honestly… I did a typo and I’ve noticed that

If you do only the first part as

scala> sample.split(",")(1)split(" ")(0)
res5: Array[String] = Array(2013-07-25, 00:00:00.0)

It returns an Array which doesn’t have split method implemented. Thats why the error message popped up.

2 Likes