Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trait Longable{ def toLong(): Long }
- implicit class IntCanLong(int: Int) extends Longable {
- def toLong(): Long = int.toLong
- }
- implicit class StringCanLong(str: String) extends Longable {
- def toLong(): Long = str.toInt.toLong
- }
- val l: List[Longable] = List(1,"5")
- val myMap = Map[String, Longable](
- "one" -> 1,
- "two" -> "2"
- )
- myMap.valuesIterator.foreach(l => println(l.toLong))
Add Comment
Please, Sign In to add comment