View opt_onlyMap.scala
// case class Rel3(id: Int, vals: Option[Map[String, Set[Int]]]) | |
val setm1 = Map(1 -> Some(Map("a" -> Set(1,2)))) | |
val setm2 = Map(1 -> Some(Map("a" -> Set(2,3)))) | |
val setm3 = Map(1 -> None) | |
val setm4 = Map(2 -> Some(Map("b" -> Set(5,6)))) | |
val all = Set(setm1, setm2, setm3, setm4) | |
import scalaz._ | |
import Scalaz._ |
View opt_caseClass.scala
case class Rel3(id: Int, vals: Option[Map[String, Set[Int]]]) | |
val setm1 = Set(Rel3(1, Some(Map("a" -> Set(1,2))))) | |
val setm2 = Set(Rel3(1, Some(Map("a" -> Set(2,3))))) | |
val setm3 = Set(Rel3(1, None)) | |
val setm4 = Set(Rel3(2, Some(Map("b" -> Set(5,6))))) | |
val all = (setm1 ++ setm2 ++ setm3 ++ setm4) | |
all.groupBy(_.id).mapValues(s => | |
// Rel3(s.head.id, Some(s.flatMap(_.vals).toList.reduce(_|+|_)))).values | |
Rel3(s.head.id, Some(s.flatMap(_.vals).toList.reduce((h1, h2) => (h1 ++ h2).map{ case (k,v) => k -> (v ++ h1.getOrElse(k,Set())) })))).values |
View play_filter_dump_body.scala
import java.net.URLDecoder | |
import play.api.Logger | |
import play.api.libs.iteratee.Iteratee | |
import play.api.mvc.{ Result, RequestHeader, Filter } | |
import play.api.libs.concurrent.Execution.Implicits.defaultContext | |
import scala.concurrent.Future | |
object LoggingFilter extends Filter { | |
override def apply(nextFilter: (RequestHeader) => Future[Result])(rh: RequestHeader): Future[Result] = { | |
val startTime = System.currentTimeMillis() |
View types_infer_ruby_foo+bar
>> foo = "aaa" | |
=> "aaa" | |
>> bar = 123 | |
=> 123 | |
>> foo + bar | |
TypeError: no implicit conversion of Fixnum into String | |
from (irb):3:in `+' | |
from (irb):3 | |
from /home/ab/.rbenv/versions/2.0.0-p247/bin/irb:12:in `<main>' |