What would be the best way to transform List[Foo] into Seq[(String, String)], considering that Foo is a Java interface like this:
public interface Foo {
Long getKey();
String getValue();
}
What would be the best way to transform List[Foo] into Seq[(String, String)], considering that Foo is a Java interface like this:
public interface Foo {
Long getKey();
String getValue();
}
You can transform them with map.
class Bar extends Foo{
| def getKey = 0
| def getValue = ""
| }
defined class Bar
scala> val bar = new Bar
bar: Bar = Bar@7fe69211
scala> val foos = Seq(bar, bar, bar)
foos: Seq[Bar] = List(Bar@7fe69211, Bar@7fe69211, Bar@7fe69211)
scala> foos.map(foo => (foo.getKey.toString, foo.getValue))
res0: Seq[(String, String)] = List((0,""), (0,""), (0,""))