Relative Content

Tag Archive for return-type

When should one use “out” parameters?

In Objective-C, there are several methods like initWithContentsOfFile:encoding:error: where one passes in a reference to an NSError object for the error: parameter. In this example, the value of the NSError object passed in can change based on what goes on at runtime when the method is being called and whether the body of the method was executed in a certain way successfully. In a way I think of this NSError object as sort of like a second return value from the method, and only differs from an object anObject in the statement return anObject; in that when this statement is called, execution leaves the method.

php return values

I have a codeigniter app and in my model, I always return true or false for all functions, and if I have data that needs to be passed, I also set a property that contains my data.

use areFoo or isFoo?

I have never seen the use of “are” for boolean methods, but the use of “is” is very common.

use areFoo or isFoo?

I have never seen the use of “are” for boolean methods, but the use of “is” is very common.

use areFoo or isFoo?

I have never seen the use of “are” for boolean methods, but the use of “is” is very common.

Intersection of geometric entities

I was trying to design a small C++ geometric API for learning purposes, but came across a problem when dealing with intersections of geometric entities. For example, the intersection of a line and a sphere can have three different types: a couple of points, a point or nothing at all. I found several ways to deal with this problem, but I don’t know which of them seems to be the best: