Reputation: 267280
I'm trying to write this java code in scala, but I am getting a compile error.
Document<String, String> doc = Document.<String, String>builder().id("newDocId").score(1d).build();
I am trying:
val doc = Document.<String, String>builder().id("newDocId").score(1d).build();
How do I convert this java generic usage?
I also tried Document[String, String] but I get an error sayingDocument is not a value.
Upvotes: 0
Views: 132
Reputation: 7604
Try this:
val doc = Document.builder[String, String]().id("newDocId").score(1d).build()
Scala uses square brackets for generics (and semicolons are optional). Also, the type parameters go to the method, not the object.
Upvotes: 4