Last active

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Example of `lazy val` inside `implicit class`

View gist:8977033
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
// `lazy val` inside `implicit class`
 
implicit class RichStream[T](s: Stream[T]) {
lazy val circular: Stream[T] =
s #::: circular
}
 
// in order to make this work with `extends AnyVal`, you have to make the
// lazy val local, as follows:
 
implicit class RichStream[T](private val s: Stream[T]) extends AnyVal {
def circular: Stream[T] = {
lazy val result: Stream[T] = s #::: result
result
}
}
 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.