1

What is the meaning of <% in Scala?

The context I see it in is an abstract class declaration that I am trying to extend. This is the important part of the class:

abstract class Index[Res <% Result[Res]]  {
    def results (term: String) : List[Res]  ...

This is the header of the Result trait:

trait Result[T] extends Any {

I was able to successfully create a class that extends Result. For simplification here, I will use this header:

class Sample extends Result[Int] {

I want results in my class (extending Index) to return type List[Sample]. I tried a few different definitions, but I always get a similar error:

No implicit view available from [type] to Result[type]

where type is whatever type I used to extend Index, i.e. :

class SampleIndex extends Index[Sample]

I think my problem comes from my misunderstanding of the <% in the definition of the abstract class. Any idea how to fix this?

pedrorijo91
  • 7,635
  • 9
  • 44
  • 82
Erika
  • 21
  • 2

1 Answers1

2

It's a view bound. check more info here

pedrorijo91
  • 7,635
  • 9
  • 44
  • 82