Chapter 1:

Coming from a Smalltalk background, I was enjoying added all kinds of 
properties to basic number types, for example:

extension Double {
    var rounded:Double {
        return round(self)
    }
}

Chapter 2: 

I upgraded to XCode8Beta4 yesterday and firstly got to change all of 
UIColor.someColor() calls to UIColor.someColor accessors.

Secondly I got to scratch my head for a while regarding the cryptic compiler 
errors I was now getting from my Double.rounded extension. I finally found that 
FloatingPoint has added a rounded() method. Creating a conflict with my rounded 
property (I presume). So removed my extension and changed all of the accesses 
of rounded to be calls to rounded(), as well as change the rounded properties I 
had made for my own Angle and Duration enums for to rounded() methods for 
consistencies sake.

Chapter 3:

At this point, I felt a bit like a Sneetch (Dr Seuss). I was basically 
shuffling empty parens around my code base to make the new version happy.

I realize it can probably never be black and white, but is there at least some 
guidelines as to when a property ought to be a niladic method, and when a 
niladic method ought to be a property?
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to