Scala / Scala interview questions
How to define class in Scala?
You can define classes with the class keyword followed by its name and constructor parameters.
class GreeterClass(prefix: String, suffix: String) { def greet(name: String){ println(prefix + name + suffix) } }
You can make an instance of a class with the new keyword.
val greeter = new Greeterclass("Hello, ", "!") greeter.greet("Welcome to Javapedia.net")
More Related questions...