Scala worksheet cannot resolve class name - IntelliJ IDEA

I am giving a lecture, the lecturer is using Eclipse, but I am using IntelliJ IDEA Community Edition 15.0.6, and the code on the Scala worksheet called rationals.scala is as follows

object rationals{
  val x = new Rational(1,2)
  x.numer
  x.denom
}

//noinspection ScalaPackageName
class Rational(x: Int, y: Int) {
  def numer = x
  def denom = y
}

The Scala worksheet worksheet will not be calculated and a warning (not an error) appears associated with the class definition that is reading

Package names do not match the directory structure, this can cause problems with resolving classes from this file

In addition, and this is odd, but perhaps significant, the number of IDEA flags and the designation as typos.

Any guidance? THX

+4
source share
2 answers

, , , . class object, :

object rationals {
  class Rational(x: Int, y: Int) {
    def numer = x
    def denom = y
  }

  val x = new Rational(1,2)
  x.numer
  x.denom
}

IntelliJ Worksheet

+3

@ @

Rational.scala , .

Eclipse IntelliJ . -

+3

All Articles