7

In specs2 there is a method called Around, documented here that has the following example:

object http extends Around { def around[T <% Result](t: =>T) = openHttpSession("test") { t // execute t inside a http session } } 

The source for this code can be found here.

I'm curious what the <% operator means in this context?

EDIT: here is a solid answer on this subject, What are Scala context and view bounds?

2
  • 2
    Google is painful to use to search for symbols, but PDF viewers are pretty good: take a look at the Scala Language Specification (or "SLS"). The term for this type restriction is "View Bounds". Commented Jul 17, 2012 at 4:27
  • I had to use this symbol-specific search engine to find it: symbolhound.com Commented Oct 23, 2016 at 11:01

1 Answer 1

6

This is a view bound. It means, that the type T must be convertible to the type Result. For more information about type bounds I recommend you http://www.cs.uwaterloo.ca/~brecht/courses/702/Possible-Readings/scala/ProgrammingInScala.pdf, starting at page 61.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.