Srinivas
Srinivas

Reputation: 2100

Cannot generate equals and hashcode in Intellij for scala

When I right click and select Generate, I only see Delegate methods and Test. Am I missing something in my installation?

class Person(val firstName : String){}
val person = new Person("Srinivas")

In the same project, I created a java class and everything works fine. Definitely IntelliJ is missing something for Scala. Any help in troubleshooting will be appreciated.

Edit: I figured it works fine in a Scala class (can see all options for creating a hashcode and equals method), but does not work in a worksheet.

Upvotes: 2

Views: 786

Answers (1)

Gal Naor
Gal Naor

Reputation: 2397

Don't you see this option? picture

However, in your case, it's preferred to convert this class to case class, so you don't need to generate equals or hashcode - it's all built-in.

case class Person(firstName: String)
val person = Person("Srinivas")

Upvotes: 4

Related Questions