Quizzes
Site Language: English
Українська
English
Русский
Programming Tests
Login
Sign Up
Programming Tests
Theory
Snippets
Papers
Landing
Android
Prices
FAQ
Cosmo Story
Terms and Conditions
Privacy Policy
Cookies Policy
Send Feedback
map
:
Content language: English
Русский
What will be the result of applying map function to the values of type Option in the following code? val number: Option[Int] = Some(3) val noNumber: Option[Int] = None val result1 = number.map(_ * 1.5) val result2 = noNumber.map(_ * 1.5) println(result1) println(result2)
map
What will be the Map size in the following code? val myMap = Map("MI" -> "Michigan", "OH" -> "Ohio", "WI" -> "Wisconsin", "MI" -> "Michigan") myMap.size
map
What will be the result of following code execution? val myMap = Map("MI" -> "Michigan", "OH" -> "Ohio", "WI" -> "Wisconsin", "MI" -> "Meechigan") myMap("MI")
map
Is it allowed to have map with keys of different types? val myMap = Map("Ann Arbor" -> "MI", 49931 -> "MI")
map
What will be the result of comparing maps where from one of map a nonexistent element is removed? val myMap = Map("MI" -> "Michigan", "OH" -> "Ohio", "WI" -> "Wisconsin", "IA" -> "Iowa") val aNewMap = myMap - "MN" aNewMap.equals(myMap)
map
What will be the result of comparing Maps with the same elements in different order? val myMap1 = Map("MI" -> "Michigan", "OH" -> "Ohio", "WI" -> "Wisconsin", "IA" -> "Iowa") val myMap2 = Map("WI" -> "Wisconsin", "MI" -> "Michigan", "IA" -> "Iowa", "OH" -> "Ohio") myMap1.equals(myMap2)
map
What will be the result of combining Semigroup of type Map with the same keys? import cats.implicits._ import cats.kernel.Semigroup val aMap = Map("foo" → Map("bar" → 5)) val anotherMap = Map("foo" → Map("bar" → 6)) val combinedMap = Semigroup[Map[String, Map[String, Int]]].combine(aMap, anotherMap) combinedMap.get("foo")
map
← Prev
1
Next →
Sign Up Now
or
Subscribe for future quizzes