intellij idea - Scala - Cannot resolve symbol - Looping through map -


i doing programming in scala looping through map.

below code works fine.

     val names = map("fname" -> "robert", "lname" -> "goren")       for((k,v) <- names ) println(s"key: $k, value : $v") 

when looping through map, if give (k,v) instead of (k,v), program not compiling. gives cannot resolve symbol error.

below loop -

     for((k,v) <- names ) println(s"key: $k, value : $v") 

i executing program in intellij idea 15 scala worksheet.

can please explain reason error.

it doesn't compile same reason code doesn't compile:

val (a,b) = (1,2) // error: not found: value // error: not found: value b 

but does compile:

val (a,b) = (1,2) // a: int = 1 // b: int = 2 

constant names should in upper camel case. is, if member final, immutable , belongs package object or object, may considered constant

method, value , variable names should in lower camel case

source: http://docs.scala-lang.org/style/naming-conventions.html


Comments

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -