Why is this Scala example of implicit paremeter not working?

Posted by Alex R on Stack Overflow See other posts from Stack Overflow or by Alex R
Published on 2010-04-25T15:07:36Z Indexed on 2010/04/25 15:13 UTC
Read the original article Hit count: 187

simple REPL test...

def g(a:Int)(implicit b:Int) = {a+b}

Why do neither of these attempted usages work?

1.

scala> class A { var b:Int =8; var c = g(2) }
:6: error: could not find implicit value for parameter b: Int
       class A { var b:Int =8; var c = g(2) }

2.

scala> class A(var b:Int) { var c = g(2) }  
:6: error: could not find implicit value for parameter b: Int
       class A(var b:Int) { var c = g(2) }
                                     ^

Thanks

© Stack Overflow or respective owner

Related posts about scala

Related posts about scala-2.8