首页 > scala andThen 用法问题

scala andThen 用法问题

case class Gen[+A](sample: State[RNG,A]) {
  def map[B](f: A => B): Gen[B] =
    Gen(sample.map(f))
}

case class SGen[+A](g: Int => Gen[A]) {
  def apply(n: Int): Gen[A] = g(n)// define SGen() => Gen

  def map[B](f: A => B): SGen[B] =
    // :?: 这个地方的 _ 的用法比较隐晦, 我也不是十分确定, 
    // 我猜是 g(Int)=>Gen 之后再用生成的 Gen示例调用 map(f) 返回一个新的 Gen示例
    SGen(g andThen (_ map f))
}

上边就是问题的上下文, 我不十分确定 andThen 的用法是否是我猜得那样。帮忙解释和确认下我的疑问


http://blog.csdn.net/li385805776/article/details/19200483

【热门文章】
【热门文章】