Hacker News new | ask | show | jobs
by asadmshah 3321 days ago
Yes.

    val person = selection?.organization?.owner?.let {
        setTitle(it.name)
        setImage(it.image)
        it
    }
3 comments

You may use `also`. It is like let but it returns the receiver.

    val person = selection?.organization?.owner?.also {
        setTitle(it.name)
        setImage(it.image)        
    }
You can use `also` instead of `let` to remove the last `it` line.
ok so I'm guessing you can't operate on more then one scope at once?

    if let person1 = dashboard?.owner, person2 = selection?.organization?.owner {
    	person1.cloneProperties(person2)
    }
You'd use nested let clauses and name the param instead of using the implicit "it"
Or just write a function to accomplish the same behavior: http://stackoverflow.com/a/35522422/364135

Would be nice if there was a multiLet in the stdlib. Probably something that happens eventually anyways.