-1

Why does the case class in Scala needs to have compulsory parenthesis().

      case class TestCase() {} 

Why it cannot be like below:

      case class TestCase {}
ZAHEER AHMED
  • 507
  • 1
  • 5
  • 9
  • 7
    Possible duplicate of [Why were the case classes without a parameter list deprecated?](http://stackoverflow.com/questions/2254710/why-were-the-case-classes-without-a-parameter-list-deprecated) – Sparko Jan 01 '16 at 07:59
  • Hmm went through the thread, but it does not give the exact answer. If you have details can you share here – ZAHEER AHMED Jan 01 '16 at 11:57

2 Answers2

1

This is to avoid mistakes. If you have a case class without args it means all case classes that you create will be identical so in most cases what you really mean is to do case object

Maxim
  • 7,268
  • 1
  • 32
  • 44
0

As case classes are the special classes, which has already defined factory methods. One of factory method is apply function(that construct the object of case class, without new keyword). Because of this apply methods functionality, we have to specify the parenthesis, which means there are no arguments to be pass in apply method and the default apply method(Without any parameters) has to be called to construct the object of that case class.