SwiftKotlin icon indicating copy to clipboard operation
SwiftKotlin copied to clipboard

let function inside lambda is translated to val

Open manuelgon47 opened this issue 7 years ago • 0 comments

        if let intent = coordinator.methodName(param1: param1, param2: param2, onComplete: {
            self.view.let { self.navigationManager.dismiss(view: $0, animated: true) }
        }) {
            navigationManager.show(intent, animation: .present)
        }

Translated:

        val intent = coordinator.methodName(param1: param1, param2: param2, onComplete = {
            this.view.val { this.navigationManager.dismiss(view = it, animated = true) }
        })
        if (intent != null) {
            navigationManager.show(intent, animation = .present)
        }

Correct Translate:

        val intent = coordinator.methodName(param1: param1, param2: param2, onComplete = {
            this.view?.let { this.navigationManager.dismiss(view = it, animated = true) }
        })
        if (intent != null) {
            navigationManager.show(intent, animation = .present)
        }

manuelgon47 avatar Feb 14 '18 11:02 manuelgon47