I am trying to implement a simple method that can be applied to any number:
/** * Round `candidate` to the nearest `bucket` value. */ def bucketise[Ordering[A]](buckets: Seq[Ordering[A]], candidate: Ordering[A]): Ordering[A] = ???
I do not want to simply parameterize completely as a whole, since my method will use comparison <and>. I think this means that I should limit any type of Ordering[_] , but I seem to be unable to specify this.
Calling the above (or the option where I replace A with _ ) causes the following error:
error: type mismatch; found : Int(3) required: Ordering[_] NumberUtils.bucketise(List(1,2,3), 3)
What is the correct syntax for what I'm trying to achieve?
source share