Hullaballoonatic
11/09/2019, 8:03 PMvar next = stack.last
get() {
field = stack.pop()
field
}
var next = stack.last
get() = field := stack.pop()karelpeeters
11/09/2019, 9:39 PMwhen just to be able to avoid adding this operator đHullaballoonatic
11/09/2019, 9:40 PMQuy D X Nguyen
11/09/2019, 9:46 PMkarelpeeters
11/09/2019, 9:47 PMwhen(val x = foo()) is allowedkarelpeeters
11/09/2019, 9:47 PMHullaballoonatic
11/09/2019, 9:50 PMif (val x = foo()) like you can in Java.elizarov
11/11/2019, 8:37 AMfun moveNext() = stack.pop().also { next = it }Hullaballoonatic
11/11/2019, 7:50 PMnext also?
and, yeah, i used also in similar code i wrote. I wasn't really writing up this code as a good example of why it'd be nice to have, but instead just showcasing how it works.
i think the better example of where they'd be applicable are in while and if statements:
if ((val n = password.length) < 6) error("pw length of $n is too short. must be >= 6")Hullaballoonatic
11/11/2019, 7:51 PMkarelpeeters
11/11/2019, 8:58 PMIterator.next() is a function.