Skip to content

Instantly share code, notes, and snippets.

@igoticecream
Last active Jan 31, 2017
Embed
What would you like to do?
Example of implicit classes on Scala
package com.igoticecream.wrike.util
object Utils {
implicit class IntWithTimes(x: Int) {
def times[A](f: => A): Unit = {
def loop(current: Int): Unit = {
if (current > 0) {
f
loop(current - 1)
}
}
loop(x)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment