scala error ambiguous reference to overloaded definition

subho

I am new to scala and trying to learn scala. I am trying to write below 2 classes but getting the below error. Please help me

scala> class Point(val x: Int,val y: Int)
defined class Point

scala> class Rectangle(val topleft: Point,val bottomright: Point){
     | def topleft: Point
     | def bottomright: Point
     | def left=topleft.x
     | def right=bottomright.x
     | def width=right-left
     | }


<console>:14: error: ambiguous reference to overloaded definition,
both value topleft in class Rectangle of type => Point
and  method topleft in class Rectangle of type => Point
match expected type ?
       def left=topleft.x
                ^


<console>:15: error: ambiguous reference to overloaded definition,
both value bottomright in class Rectangle of type => Point
and  method bottomright in class Rectangle of type => Point
match expected type ?
       def right=bottomright.x
                 ^
<console>:13: error: value bottomright is defined twice
  conflicting symbols both originated in file '<console>'
       def bottomright: Point
           ^

<console>:12: error: value topleft is defined twice
  conflicting symbols both originated in file '<console>'
       def topleft: Point

Thanks and Regards,

notionquest

Please define the Rectangle class as below without topleft and bottomright:-

scala> class Rectangle(val topleft: Point,val bottomright: Point){
     | def left=topleft.x
     | def right=bottomright.x
     | def width=right-left
     | }
defined class Rectangle

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

"ambiguous reference to overloaded definition" when using Java class in Scala

From Dev

How to solve ambiguous reference to overloaded definition

From Dev

ambiguous reference to overloaded definition, from a Java library

From Dev

Mockito doReturn: ambiguous reference to overloaded definition

From Dev

ambiguous reference to overloaded definition, from a Java library

From Dev

ambiguous overloaded function reference

From Dev

Disambiguate ambiguous reference to overloaded definiton

From Dev

reference to overloaded methods in scala

From Dev

Scala eta expression ambiguous reference doesn't list all overloaded methods

From Dev

Error: ambiguous call to overloaded function

From Dev

error: use of overloaded operator '*' is ambiguous

From Dev

Scala: Function definition of PartialFunction is ambiguous

From Dev

IObservable ambiguous reference error

From Dev

reference to println is ambiguous error

From Dev

Queryable attribute ambiguous Reference Error

From Dev

Queryable attribute ambiguous Reference Error

From Dev

"Ambiguous reference to member 'count' " Error

From Dev

Confused by Ambiguous Reference Member Reference error in Swift

From Dev

How to resolve ambiguous method reference in scala

From Dev

How to provide ambiguous reference in scala inherit trait?

From Dev

Compile time error: ambiguous on calling overloaded method. Why?

From Dev

Getting: error C2668: 'sqrt' : ambiguous call to overloaded function

From Dev

Using float gives "call to overloaded function is ambiguous" error

From Dev

Error message "is ambiguous for the type Other" when calling an overloaded method

From Dev

Compile time error: ambiguous on calling overloaded method. Why?

From Dev

Error C2668: 'boost::bind' : ambiguous call to overloaded function

From Dev

Scala error: "forward reference extends over definition of value" when code appears in a function

From Dev

In Scala what is the correct way to fix "error: forward reference extends over definition of value"?

From Dev

Puzzling "reference to println is ambiguous" compilation error

Related Related

  1. 1

    "ambiguous reference to overloaded definition" when using Java class in Scala

  2. 2

    How to solve ambiguous reference to overloaded definition

  3. 3

    ambiguous reference to overloaded definition, from a Java library

  4. 4

    Mockito doReturn: ambiguous reference to overloaded definition

  5. 5

    ambiguous reference to overloaded definition, from a Java library

  6. 6

    ambiguous overloaded function reference

  7. 7

    Disambiguate ambiguous reference to overloaded definiton

  8. 8

    reference to overloaded methods in scala

  9. 9

    Scala eta expression ambiguous reference doesn't list all overloaded methods

  10. 10

    Error: ambiguous call to overloaded function

  11. 11

    error: use of overloaded operator '*' is ambiguous

  12. 12

    Scala: Function definition of PartialFunction is ambiguous

  13. 13

    IObservable ambiguous reference error

  14. 14

    reference to println is ambiguous error

  15. 15

    Queryable attribute ambiguous Reference Error

  16. 16

    Queryable attribute ambiguous Reference Error

  17. 17

    "Ambiguous reference to member 'count' " Error

  18. 18

    Confused by Ambiguous Reference Member Reference error in Swift

  19. 19

    How to resolve ambiguous method reference in scala

  20. 20

    How to provide ambiguous reference in scala inherit trait?

  21. 21

    Compile time error: ambiguous on calling overloaded method. Why?

  22. 22

    Getting: error C2668: 'sqrt' : ambiguous call to overloaded function

  23. 23

    Using float gives "call to overloaded function is ambiguous" error

  24. 24

    Error message "is ambiguous for the type Other" when calling an overloaded method

  25. 25

    Compile time error: ambiguous on calling overloaded method. Why?

  26. 26

    Error C2668: 'boost::bind' : ambiguous call to overloaded function

  27. 27

    Scala error: "forward reference extends over definition of value" when code appears in a function

  28. 28

    In Scala what is the correct way to fix "error: forward reference extends over definition of value"?

  29. 29

    Puzzling "reference to println is ambiguous" compilation error

HotTag

Archive