December 2013
Beginner
576 pages
16h 4m
English
When creating the name for a method, the argument names are actually optional. For example, you can declare a method like this:
-(int) set: (int) n: (int) d;
Note that, unlike in previous examples, no name is given for the second argument to the method here. This method is named set::, and the two colons mean the method takes two arguments, even though they’re not all named.
To invoke the set:: method, you use the colons as argument delimiters, as shown here:
[aFraction set:1 :3];
It’s not good programming style to omit argument names when writing new methods because it makes the program harder to follow and makes the purpose of the method’s actual parameters less intuitive.
Read now
Unlock full access