I see many people wanting collection literals, but...
# language-proposals
j
I see many people wanting collection literals, but obviously there’s many problems in adding it in the language, like is
{  }
a linkedHashMap, ConcurrentHashMap, etc Suggestion, just like you can do operator overloading, maybe it’s worth providing something that allows literal overloading without actually providing a default implementation for it.
Copy code
val listOfStrings = ["a", "b", "c"];
this will fail unless you extend String and give it squareBrackets implementation
Copy code
literal fun  String.squareBrackets(varargs String values)  {
   // package values in whatever type of List you want
}
Not sure if the extensions should happen on String or on MutableList for example if you want MutableList to be your implementation of the square brackets literals. Same for
{   }
, allow literal extensions / overriding while the default implementation simply throws a NotImplementedException.