A Java event logging (analytics) library has a method that takes an event name and then varargs list of Strings like this:
Analytics.event("my event name", "key1", "value1", "key2", "value2" ...)
I’ve collected my event parameters in to a Map like
Map("key1" -> "value1", "key2" -> "value2" ...)
Now there must be a way to flatten the Map to list where keys and values alternate and then feed it to the event method. I’ve had several guesses, like transforming the Map to list a List of Tuples, but calling .flatten on that says
No implicit view available from (java.lang.String, java.lang.String) => scala.collection.TraversableOnce[B]
What am I missing here?
You can use the
: _*operator:Not sure whether this works with Java varargs as well (let us know!)