Hi all, very general Kotlin question here. Is the...
# announcements
t
Hi all, very general Kotlin question here. Is there a way to access a property of a context object when using when clause? For example let's say I have someObj reference which has a string property of propOfSomeObj. when (someObj) { ::propOfSomeObj.isBlank() -> ... }
🚫 1
@Ruckus, gotcha. Thanks very much for your reply. Really appreciate it!
s
Actually you sort of can. You can assign the context to a val. This is valid:
Copy code
when(val it = someObj) {
  it.propOfSomeObj.isBlank() -> 
}
However it does add some verbosity. I agree it would be nice for the context to be bound to some default name
Oh crap, yeah, you’re right. I should not code after midnight 😉