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 6916443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:36:14+00:00 2026-05-27T09:36:14+00:00

The trait Map[A,+B] has a method def minBy [B] (f: ((A, B)) ⇒ B)(implicit

  • 0

The trait Map[A,+B] has a method

def minBy [B] (f: ((A, B)) ⇒ B)(implicit cmp: Ordering[B]): (A, B)

I expected the B of the trait to be the same as the one in the method, but then I can’t still make sense of this:

val m2 = Map('a -> "1", 'b ->"2" ,'c ->"3")
m2.minBy((t:(Symbol,String))=>Integer.parseInt(t._2))

Here, B of Map[A,+B] is String, but B of minBy is Int – or err I?

So I expected the type of the method to be rather

def minBy [C] (f: ((A, B)) ⇒ C)(implicit cmp: Ordering[C]): (A, B)

But thats not what the source says.

If both are distinct, where should I have known?
If they are not – can you spot, and point out, my mistake?

  • 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-27T09:36:14+00:00Added an answer on May 27, 2026 at 9:36 am

    You analysis is correct, it should be renamed as C, or something else. The problem is that scaladoc is simply replacing the A in the definition in TraversableLike with a Tuple (A, B) because it’s a map. This is the definition from TraversableLike:

    def minBy [B] (f: (A) ⇒ B)(implicit cmp: Ordering[B]): A
    

    because it’s a map, scaladoc replaces the (A) with a tuple (A, B).

    def minBy [B] (f: (A, B) ⇒ B)(implicit cmp: Ordering[B]): (A, B)
    

    which as you observe, isn’t actually the correct signature.

    This is a known issue, scaladoc does not disambiguate between same-named type parameters. Vote it up or submit a patch!

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

Sidebar

Related Questions

Scala's MapLike trait has a method mapValues [C] (f: (B) ⇒ C): Map[A, C]
Why can't I add to a scala.collection.Map ? It seems that this trait is
My game has class Enemy who's AI/functionality I can change with trait Moving trait
I've implemented a Listenable/Listener trait that can be added to Actors. I'm wondering if
I'm trying to write a method which takes a Map[K, Collection[V]] and converts it
I'am trying to write something like this: trait Typed[T] trait Test { def testMap:
Let's assume I want to create a trait that I can mix in into
Trait Traversable has methods such as toList , toMap , ToSeq . Given that
How can I design a method which returns a path dependent type? In the
I'm trying to write a trait (in Scala 2.8) that can be mixed in

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.