Question: I have a function that should return `String` or `Array`:

```
func someFunc(isList:Bool=false) -> AnyObject {
        if isList {
            var results:[AnyObject] = [11, "123", [], "22"]
            return results
        } else {
            var result = "123"
            return result
        }
    }

```

But compiler says:

> 
> Return expression of type '[AnyObject]' does not conform to
>  'AnyObject'
> 
> 
>

Answer: 
Your results variable needs to be of type AnyObject instead of [AnyObject]. Basically, you need to cast the array of AnyObjects to a single AnyObject

```
func someFunc(isList:Bool=false) -> AnyObject {
    if isList {
        var results: AnyObject = [11, "123", [], "22"]
        return results
    } else {
        var result = "123"
        return result
    }
}

```
"AnyObject" is any *object*. [AnyObject] is an array, and arrays are values, not objects. And the other value you try to return is a string, which is also a value, not an object. 

Your function should either return Any, or better yet an enum with two cases, one case [Any] and one case String.