dictionary - How to find the number of (key , value) pairs in a map in scala? -
I need to find the number of keys (key, values) in the map of my Scala code. I repeat through the map I can get an answer and I want to know whether there is any direct task for this purpose.
you can use
scala> Val m = map ("one" -> 1, "b" -> 2, "c" -> 3) m: scala.collection.immutable.Map [string, int] = map (a - & Gt; 1, b -> 2, c -> 3) Skeleton & gt; M.size res3: int = 3
Comments
Post a Comment