Need help in scala

hi All,

Please help me in the scala code. i am new to scala with no java background.
The code is not giving any compilation error. However its not giving output also.
Not sure what am missing in my code. Please help

Question is

The Expression abstract class is created with 4 other case classes. Write a function which takes an Expresssion object as input, and use match so that when an Expression object is taken:

  1. It is a number is printed for Number object.
  2. It is a string expression is printed for Var object.
  3. It is a unary operation is printed for UnOp object.
  4. It is a binary operation is printed for BinOp object.
  5. Invalid Expression is printed in all other cases.

my code is

abstract class Expression
case class Var(name: String) extends Expression
case class Number(num: Double) extends Expression
case class UnOp(operator: String, arg: Expression) extends Expression
case class BinOp(operator: String, left: Expression, right: Expression) extends Expression
object CaseClassMatching extends App {
val op = BinOp("+", Number(1), Number(4))
def describe (i: Expression): String = i match {
case Var() => “Its is string expression”
case Number(
) => " It is a number"
case UnOp(,) => " it is a unary operation"
case BinOp(,,_) => " it is a binary operation"

Hi, welcome to the community.

For future posts, you can format your code like this:

// your code here.

Now, you already basically solve your problem.
The only thing is a that you are not printing the answer.

Just do this


Happy coding.

Thank you very much Sir. it worked perfectly and came to know what i am missing.