[kotlin] Val and Var in Kotlin

In short, val variable is final (not mutable) or constant value that won't be changed in future and var variable (mutable) can be changed in future.

class DeliveryOrderEvent(val d : Delivery)
// Only getter

See the above code. It is a model class, will be used for data passing. I have set val before the variable because this variable was used to get the data.

class DeliveryOrderEvent(var d : Delivery)

// setter and getter is fine here. No error

Also, if you need to set data later you need to use var keyword before a variable, if you only need to get the value once then use val keyword