4

I am confused with this symbol <: and the return type T=>T. This seem to return a function. I got a function back when unit testing this function. How do I check the result ?

   def prepend[T <: Message](node: Set[String]): T => T = { out =>
    ...
   out.append("test")
   }
user3044440
  • 115
  • 9

1 Answers1

3
T <: Message

Means T should be any type that extends Message.

Now function equality/isomorphism is TTBOMK not possible. This means there is not way to compare a == b where a: T=>T and b: T=>T.

You can only generate random inputs and confirm that they are giving the same result. Not a proof of equality but it might be better than nothing.

If your result is val t: T=>T = prepend(...) you can run t as t(some T).

marios
  • 8,874
  • 3
  • 38
  • 62