UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

SOLVED: Day 11 Extensions

Forums > 100 Days of SwiftUI

extension String {
    var isLong: Bool {
        return count > 25
    }
}

shouldn't this be wrong

thats right :

extension String {
    var isLong: Bool {
        return self.count > 25
    }
}

don't we have to use self

3      

You don't necessarily need to use self within an extension when referring to properties of the thing being extended. It only becomes necessary if the compiler needs additional information. It doesn't hurt anything to use it, though, so if it makes more sense to you to do so, then by all means do.

3      

Howdy,

Another thing to keep in mind is 99.6% of what you learn from Paul is accurate, however some of these videos were made back when XCode 9.3 was being used. The information is almost entirely correct...excpet .self which received a major update with XCode 12.

There is nothing wrong with using .self, however XCode was improved & many times we do not need to use .self anymore.

3      

TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts!

Find out more

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.