Reputation: 213
How do i achieve the same result in scala.
Map<String, Integer> lookup =
new TreeMap<String, Integer>(String.CASE_INSENSITIVE_ORDER);
lookup.put("One", 1);
lookup.put("tWo", 2);
lookup.put("thrEE", 3);
System.out.println(lookup.get("Two"));
System.out.println(lookup.get("three"));
Upvotes: 0
Views: 147
Reputation: 40500
It's not that it's "unable to do the same" so much as you are unable to figure out how ;)
scala> scala.collection.immutable.SortedMap("foo" -> "bar")(Ordering.by(_.toLowerCase)).get("Foo")
res10: Option[String] = Some(bar)
Upvotes: 7