Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

func DisplayArray<SomeType>(array:[Int]){ //code here } hi guys , anyone know what is this <SomeType> ??

func DisplayArray<SomeType>(array:[Int]){ //code here } hi guys , anyone know what is this <SomeType> ??

1 Answer

J.D. Sandifer
J.D. Sandifer
18,813 Points

Hi, Wilztan. My Swift is a little rusty, but I believe this is trying to be a generic function definition. However, I believe it should be:

func DisplayArray<SomeType>(array:[SomeType]){ //code here } - That would mean it is a function that takes an array argument, but the array can be of any type. The type is later specified in the function call like this - DisplayArray<Int>(someArrayWithInts). (The //code here part is where the actual code for the function would go - presumably to display the array...)

OR

func DisplayArray(array:[Int]){ //code here } - This would be the same function, but it would only work with an int array as the argument.

Hope that helps!

not that, the way you say i understand but look at this code

func DisplayArray<SomeType>(array:[Int]){

}

DisplayArray<SomeType> mean what?