WWDC24 SALE: Save 50% on all my Swift books and bundles! >>

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      

Save 50% in my WWDC sale.

SAVE 50% To celebrate WWDC24, all our books and bundles are half price, so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.

Save 50% on all our books and bundles!

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.