MCQs > IT & Programming > Scala > Choose the correct statement which explains the error?

Scala MCQs

Using the code fragment below, Choose the correct statement which explains the error?

object Main extends App { def mySum[T <: Number](as: T*): Double = as.foldLeft(0d)(_ + _.doubleValue) implicit def intToInteger(n: Int): Integer = new Integer(n.toInt) var r = mySum(2, 3) } When complied produces the following error Main.scala:4: error: inferred type arguments [Int] do not conform to method mySum's type parameter bounds [T <: Number] var r = mySum(2, 3) ^

Answer

Correct Answer: [T <: Number] type bounds means that T must be a subtype of Number

Explanation:

Note: This Question is unanswered, help us to find answer for this one

Scala Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it

search

Scala Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it