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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:00:57+00:00 2026-05-30T22:00:57+00:00

A class of mine is a generic and defines iv as MHashMap[DateTime, T] .

  • 0

A class of mine is a generic and defines iv as MHashMap[DateTime, T]. MHashMap is an alias for scala.collection.mutableHashMap. Then I use this code to expose a minimum finding functionality

def minimum: BigDecimal = {
  iv match {
    case dtMcM: MHashMap[DateTime, MyCustomClass] => dtMcM.minBy(_._2.bdField)._2.bdField
    case dtBdM: MHashMap[DateTime, BigDecimal] => dtBdM.minBy(_._2)._2
    case dtDlM: MHashMap[DateTime, Double] => dtDlM.minBy(_._2)._2.toBigDecimal
    case dtItM: MHashMap[DateTime, Int] => dtItM.minBy(_._2)._2
    case _ => throw new IllegalArgumentException("Unsupported underlying type")
  }
}

But the complier complains:

No implicit Ordering defined for T with Int.
case dtItM: MHashMap[DateTime, Int] => dtItM.minBy(_._2)._2

And the same for Double and BigDecimal cases.

How is that the compiler can not even recognize Int to apply default ordering? Curious thing is that it desn’t seem to have any problem with a BigDecimal field of my own custom class.

  • 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-30T22:00:58+00:00Added an answer on May 30, 2026 at 10:00 pm

    Well, Int <: T with Int. Now, if you are going to use Ordering[Int] for it, then you need Ordering[T with Int] <: Ordering[Int], which means Ordering must be contravariant. Unfortunately, Ordering is not contravariant (even though it could — and it is in Scalaz).

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

Sidebar

Related Questions

I have the following code in a class of mine. The purpose of this
This is related to a prior question of mine C# Generic List conversion to
Inside a class of mine I have the following code: mHandler = createHandler(); private
I'm expanding a class of mine for storing generic size strings to allow more
Class is a reference types while Struct is a value type. This means that
In Symfony2, a service is defined as [emphasis mine]: A Service is a generic
I have a class of mine, lets call it TMyObject, which should return a
so I am able to successfully have another class of mine be notified via
I have a case where an action requests some class of mine. I created
All, I'm trying to send the NSMutableDictionary response to another class of mine, or

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.