"multiple overloaded alternatives of method ... define default arguments"

1,229 views
Skip to first unread message

Kevin Meredith

unread,
Oct 21, 2015, 12:34:15 PM10/21/15
to scala-user

Why can't I overload two methods with default arguments, as shown below?


$scala

Welcome to Scala 2.12.0-M3 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_51).

Type in expressions for evaluation. Or try :help.


scala> :paste

// Entering paste mode (ctrl-D to finish)


def f(x: Int, y: String = "bar") = true

def f(x: Boolean, y: String = "foo") = false


// Exiting paste mode, now interpreting.


<console>:9: error: in object $iw, multiple overloaded alternatives of method f define default arguments.

object $iw {

       ^


Thanks,

Kevin

Jason Zaugg

unread,
Oct 21, 2015, 9:30:55 PM10/21/15
to Kevin Meredith, scala-user

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages