How to define a method in Scala that returns a Java object?

Viewed 60506

I want to define a private method in scala singleton class that looks like;

private def  createDomNode(tag: String, attrs: Map[String , String]): DomNode  {

}

DomNode is Java type, not scala type. attrs is scala Map with both key and value being of type String.

But above gives error. What is the correct format?

Thanks Easy Angel for the answer. There is still some confusion. According to Programming in Scala book written by the inventor of the language, the below is a function:

def max(x: Int, y: Int): Int = {
  if (x > y) x
  else y
}

But your answer says it is method and not function. Can you kindly explain?

What is REPL?

1 Answers
Related