0
Studying some projects, I found an intriguing code, where in addition to the clause class that defines an object, already known from Java, there is the clause object, unknown to me until then.
object Counter {
val InitialValue = 10000000L; // (ten million)
val CounterKey = "counter"
}
@Singleton
class Counter @Inject()(
client: JedisClient) {
def next: Long = {
val current: Long = Option(client.get(CounterKey)) match {
case Some(value) =>
value.toLong
case None =>
InitialValue
}
val nextValue = current + 1
client.set(CounterKey, nextValue.toString)
nextValue
}
}
What the object Counter defines in this case?