Software Development

Immutable Objects Using Annotation In Groovy

In Groovy, it is possible to create an immutable using the groovy.transform.Immutable annotation. One possible use-case for this is when we want to create a object (with data initialized through the class constructor) that is passed to another application layer (e.g., service) but we don’t want that object modified in that layer.

Software Development

Kotlin – val versus var

What is the difference between the keywords val and var in Kotlin? If you’re coming from Java, val refers to variable that cannot be updated after it has been assigned a value; while var is the usual writable variable whose value can always be changed by other codes.