case class Foo(k: Int, v: String)
def main(args: Array[String]) {
val foos = List(Foo(1, "a"), Foo(2, "b"), Foo(3, "c"))
val map: Map[Int, String] = foos.map(f => (f.k, f.v)).toMap
println(map)
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.