This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.collection.{immutable, mutable, GenTraversableOnce} | |
import scala.collection.generic.CanBuildFrom | |
object GroupableOps { | |
implicit class ToGroupable[A, Coll[X] <: GenTraversableOnce[X]](coll: Coll[A]) { | |
// https://github.com/scala/scala/blob/v2.13.0-M5/src/library/scala/collection/Iterable.scala#L578 | |
def groupMap[K, B, To](key: A => K)(f: A => B) | |
(implicit bf: CanBuildFrom[Coll[A], B, To]): immutable.Map[K, To] = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.intenthq.elasticsearchwriter.duration | |
import java.util.Locale | |
import java.util.concurrent.TimeUnit | |
import scala.concurrent.duration._ | |
object PrettyDuration { | |
private val abbreviate = Map( | |
NANOSECONDS -> "ns", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Main extends App { | |
case class User(id: String, name: String) | |
val users = scala.collection.mutable.Map( | |
"1" -> User("1", "Fernando"), | |
"2" -> User("1", "Darren"), | |
) | |
object UserRepository { | |
def getUserById(id: String): Option[User] = { |
OlderNewer