Native elegant way of do() function of "Then" framework

I have encounter a framework called "Then" syntactic sugar for Swift initializers and liked the way do function seems like clear to me. Can i use some function or extension to get rid of my instance repeating itself without using "Then" ?

let tableView = UITableView()

tableView.do {
        $0.backgroundView = UIView()
        $0.backgroundView?.isHidden = true
        $0.backgroundColor = .white
        $0.register(UserListCell.self, forCellReuseIdentifier: String(describing: UserListCell.self))
    }

my intend is something like this:

let tableView = UITableView()
tableView.extensionfunc() {
$0.backgroundView = UIView()
$0.backgroundView?.isHidden = true
$0.backgroundColor = .white
$0.register(UserListCell.self, forCellReuseIdentifier: String(describing: UserListCell.self))
}


Read more here: https://stackoverflow.com/questions/64414186/native-elegant-way-of-do-function-of-then-framework

Content Attribution

This content was originally published by DrainOpener at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: