[mod] modified traversableToMap to have a default function

This commit is contained in:
2020-01-29 01:19:11 -06:00
parent 86e383922d
commit 961d14e96e

View File

@@ -115,7 +115,7 @@ package object convertUtil {
package object mapUtil { package object mapUtil {
def traversableToMap[A, B](traversable: Traversable[Any], getTuple: (Any) => (A, B)): Map[A, B] = { def traversableToMap[A, B](traversable: Traversable[Any], getTuple: (Any) => (A, B) = (e: Any) => e.asInstanceOf[(A, B)]._1 -> e.asInstanceOf[(A, B)]._2): Map[A, B] = {
// Traversable[Tuple[A, B]] can be converted via .map // Traversable[Tuple[A, B]] can be converted via .map
// .foldLeft used in favor of .map().toMap as the latter needs two traversals // .foldLeft used in favor of .map().toMap as the latter needs two traversals
// traversable.map(e => getKey(e) -> getValue(e)).toMap // traversable.map(e => getKey(e) -> getValue(e)).toMap