SwiftKotlin icon indicating copy to clipboard operation
SwiftKotlin copied to clipboard

Guard with more than one let

Open manuelgon47 opened this issue 6 years ago • 0 comments

Swift:

guard array.count > row,
            let a = CustomView.viewFor(item: array1[column].array[row]), 
            let b = something(a) else {
                return UIView()
            }
           ...

Tool Return:

val a = CustomView.viewFor(item = array1[column].array[row])
val b = somethin(a)
if (array.size <= row || playerView == null || b == null) {
    return UIView()
}
...

Correct return:

if (array.size <= row) return UIView()
val a = CustomView.viewFor(item = array1[column].array[row]) ?: return UIView()
val b = somethin(a) ?: return UIView()
...

manuelgon47 avatar Mar 06 '18 11:03 manuelgon47