January 2018
Intermediate to advanced
434 pages
14h 1m
English
Let's now look at the given steps to understand the vetoable modifier:
fun main(args: Array<String>) { var student:Student by Delegates.vetoable(Student(10),{property, oldValue, newValue -> if(newValue.age>25){ println("Age can't be greater than 25") return@vetoable false } true }) student=Student(26)}class Student(var age:Int)
//Output: Age can't be greater than 25
Read now
Unlock full access