I'm trying to achieve method overloading within an object by declaring function with val, but it doesn't work as expected (changing val to def makes no difference):
object B {
val p: (=> Unit) = println(1)
val p: (Int => Unit) = (i) => println(i) # p is already defined in the scope
}
But if I use def everything works well:
object A {
def p() = println(1)
def p(i: Int) = println(i)
}
The reason why I'm using the first way is I already have a type alias for a function (let's say type printit = Int => Unit, and I'm not sure how to use that printit type with def.
Any help will be really appreciated! Thank you!