For testability purposes (and to make things easier to reason about), sometimes it's nice if methods in a class are pure functions, that is, they don't contain any explicit or implicit references to self
, or really anything other than the arguments that are passed in.
In the painfully contrived example below, method
is a method (because it references both a property and another method
using self
) and isEven
is a pure function (because it doesn't).
class MyClass {
let number: Int
init(number: Int) {