SwiftLint icon indicating copy to clipboard operation
SwiftLint copied to clipboard

Swift type checking using is

Open inotetw opened this issue 1 year ago • 2 comments

New rule request

type ching using is

Bad

if  a as? Dog  != nil { 
   doSomeThing()
}

Good

if  a is Dog  { 
   doSomeThing()
}

if  let dog = dog as? Dog  { 
   dog.run()
}

type checking using "is" is more easy to understand then type casting and check nil

inotetw avatar Oct 21 '23 15:10 inotetw

I will take this one

AballahNsour avatar May 17 '24 17:05 AballahNsour

I will take this one

There has been some work in https://github.com/realm/SwiftLint/pull/5561 already.

SimplyDanny avatar May 17 '24 17:05 SimplyDanny