Read the code carefully before you run it.
fun main() {
val categories = listOf("Tools", "Electronics", "Tools", "Office")
val categoriesSet = categories.toSet()
println(categories.size)
println(categoriesSet.size)
}
Which two numbers does this program print?
A warehouse management system manages products. Outside main() (top level, which works for val just as well as inside a function) create three declarations: val productNames as a List<String> with the entries "Screwdriver", "Hammer", "Screwdriver", "Pliers" (the item "Screwdriver" really is in stock twice, so it is deliberately duplicated). val categories as a Set<String> with the entries "Tools", "Tools", "Electronics" — use setOf for that. val prices as a Map<String, Double> that maps the product "Hammer" to the price 12.5 and "Pliers" to the price 8.0. Finally print productNames.size, categories.size and prices["Hammer"] in main() (three println calls).
Before you get a hint: what have you tried, and where exactly are you stuck?
1. What does setOf("A", "A", "B") return?
2. Which statement about Map is true?
3. What is true about the relationship between List, Set and Map?