相关疑难解决方法(0)

如何在重复之前进行Scala控制抽象?

我是Peter Pilgrim.我看过Martin Odersky在Scala中创建了一个控件抽象.但是我似乎还没有在IntelliJ IDEA 9中重复它.它是IDE吗?

package demo

class Control {

  def repeatLoop ( body: => Unit ) = new Until( body )

  class Until( body: => Unit ) {
    def until( cond: => Boolean ) {
      body;
      val value: Boolean = cond;
      println("value="+value)
      if ( value ) repeatLoop(body).until(cond)
      // if  (cond) until(cond)
    }
  }

  def doTest2(): Unit = {
    var y: Int = 1
    println("testing ... repeatUntil() control structure")
    repeatLoop {
      println("found y="+y)
      y = y + 1
    }
    { …
Run Code Online (Sandbox Code Playgroud)

controls abstraction scala repeat

10
推荐指数
4
解决办法
2845
查看次数

标签 统计

abstraction ×1

controls ×1

repeat ×1

scala ×1