implicit parameter definition in class

Posted by coubeatczech on Stack Overflow See other posts from Stack Overflow or by coubeatczech
Published on 2010-03-20T00:23:29Z Indexed on 2010/03/20 0:31 UTC
Read the original article Hit count: 326

Filed under:
implicit val odkaz = head;
def vypis(implicit odkaz:Prvek):String = {
    odkaz match{
        case null => ""
        case e => e.cislo + " " + e.pocet + "\n" + vypis(e.dalsi)
    }
}

...

def main(args:Array[String]){
    val q = new MyQueue() // insert some values
    println(q.vypis)
}

This method(vypis) is a member of an queue-class so I'll always want to implicity start the recursion from the start of the queue, when calling the method from outside. Is there a way how to write it, that the method from outside calling, there's no paramter, but in inside, there's a parameter - for recursion...? The compiler complains that the parameter is not defined when called from outside

© Stack Overflow or respective owner

Related posts about scala