Help with Scala case class Lab

Hi All,

I am new to Scala and currently doing hands on as part of learning Scala.

I need assistance with below hands on, which I believe is matching the requirement but HackerRank test case is failing. Not sure what exactly the issue.

Question :

Program I did for the same :
object Result {
// Create a case class book with name(string) and author(string)
case class book(name:String,author:String)
def describe() {
//Create the two case class objects as described in the statement
val book1 =“Scala for the impatient”,“Cay S. Horstmann”)
val book2 =“Scala Cookbook”,“Alvin Alexander”)
//Print the details here
println (s"Author of this ${} is ${}")
println (s"Author of this ${} is ${}")


object Solution {
def main(args: Array[String]) {

Output received after running the HackerRank test case :
No test case passed. Use print or log statements to debug why your hidden test cases are failing. Hidden test cases are used to evaluate if your code can handle different scenarios, including corner cases.

Test case 0

Your Output (stdout)

  • Author of this Scala for the impatient is Cay S. Horstmann

  • Author of this Scala Cookbook is Alvin Alexander

(Meta-request: when you post code here, please surround it with triple-backticks – ``` – on lines by themselves, before and after the code. That will display the code in monospace, and keep the indentation, making it more readable.)

Looking at it, I have to assume this is a problem at the HackerRank level – some assumption they are making that isn’t entirely obvious. Your Scala code looks entirely reasonable to me as it is.

I know very little about HackerRank or how it works, but I wonder if the instructions have a capitalization typo, given that the name of the book should be Scala for the Impatient. I could imagine that the test case is actually looking for that, and the person writing the instructions got it wrong.


Thank you, that was the issue and once updated as Scala for the Impatient, it passed the test case :slight_smile: Thanks once again.

1 Like