So, I have a question about how my class and struct interfaces should look like in Swift. For example I have a class or struct which has method:
func getAllObjectsFromSomewhere() -> [Int]
but, imagine that this method not always return you some array of Int, so there are few different ways how to handle it.
func getAllObjectsFromSomewhere() -> [Int]?func getAllObjectsFromSomewhere() throws -> [Int]Throws custom ErrorType with types like: NotFound or EmptyArrayfunc getAllObjectsFromSomewhere() -> [Int] { /* some code and then just return an empty Int array */ return [Int]() }
So, my question is, when and why I should take which approach of organising the interface? Does it make much difference? Is there any guidelines?