Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 818967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:13:54+00:00 2026-05-15T02:13:54+00:00

I have been working on a project in scala, but I am getting some

  • 0

I have been working on a project in scala, but I am getting some error messages that I don’t quite understand. The classes that I am working with are relatively simple.
For example:

abstract class Shape
case class Point(x: Int, y: Int) extends Shape
case class Polygon(points: Point*) extends Shape

Now suppose that I create a Polygon:

val poly = new Polygon(new Point(2,5), new Point(7,0), new Point(3,1))

Then if I attempt to determine the location and size of the smallest possible rectangle that could contain the polygon, I get various errors that I don’t quite understand.

Below are snippets of different attempts and the corresponding error messages that they produce.

val upperLeftX = poly.points.reduceLeft(Math.min(_.x, _.x))

Gives the error:
“missing parameter type for expanded function ((x$1) => x$1.x)“

val upperLeftX =  
         poly.points.reduceLeft((a: Point, b: Point) => (Math.min(a.x, b.x)))

Gives this error:
“type mismatch;
found : (Point, Point) => Int
required: (Any, Point) => Any
“

I am very confused about both of these error messages. If anyone could explain more clearly what I am doing incorrectly, I would really appreciate it. Yes, I see that the second error says that I need type “Any” but I don’t understand exactly how to implement a change that would work as I need it. Obviously simply changing “a: Point” to “a: Any” is not a viable solution, so what am I missing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T02:13:55+00:00Added an answer on May 15, 2026 at 2:13 am

    The type of reduceLeft is reduceLeft[B >: A](op: (B, A) => B): B, A is Point, and you are trying to apply it to (a: Point, b: Point) => (Math.min(a.x, b.x)).

    The compiler reasons thus: Math.min(a.x, b.x) returns Int, so Int must be a subtype of B. And B must also be a supertype of Point. Why? B is the type of the accumulator, and its initial value is the first Point in your Polygon. That’s the meaning of B >: A.

    The only supertype of Int and Point is Any; so B is Any and the type of op should be (Any, Point) => Any, just as the error message says.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working with Struts for some time, but for a project I
I have been working on a project that has 2 interfaces - windows forms
I have a project that I have been working on for a while, just
On a recent project I have been working on in C#/ASP.NET I have some
I have recently been working with someone on a project that is very ajax
I have been encountering this error for my project, which involves working with Digital
I have been working on a Java project for a class for a while
I have been working on a web services related project for about the last
I am about to start a web project and have been working almost exclusively
I've been working on a project in Delphi 7 where I wanted to have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.