Counter

Report a typo

Sometimes it is convenient to create wrappers for simple data types in order to have additional methods and context.
Write a Counter case class with a special method that will increment the counter value.

The following code must work:

val counter = Counter(1)

counter.increase // Counter(2)
counter.increase.increase.increase // Counter(4)

val counterFrom100 = Counter(100)

counterFrom100.increase // Counter(101)

Sample Input 1:

1

Sample Output 1:

Counter(2)
Write a program in Scala 3
// your code
___

Create a free account to access the full topic