I would like to do in Scala what I would do in Java, for example:
public void recv(String from) { recv(from, null); } public void recv(String from, Integer key) { }
In Scala, I could do:
def recv(from: String, key: Int = null.asInstanceOf[Int]) { }
but looks ugly. Or I could do:
def recv(from: String, key: Option[Int] = None) { /* ... */ }
but now the call with red looks ugly:
// case 2 recv("/x/y/z", Some(1));
What is the correct way to Scala? Thanks.
source share