3

I'm trying to create a function to return Range but I'm getting this error:

reference to generic type Range requires arguments in...

This is my code:

func rangOfSubString(msgStr:String) -> Range {

   ...
}

Any of you knows why or a way to work around this error?

I'll really appreciate your help.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
user2924482
  • 8,380
  • 23
  • 89
  • 173
  • 1
    Update your question with the complete error message and point out the exact line of code causing the error. – rmaddy Nov 17 '16 at 22:28

1 Answers1

3

Range is a generic public struct as is defined here in swift->Collection->Range

public struct Range<Bound : Comparable>
{
  ....
}

so you need to specify the type of data that will have and must implement the comparable protocol, use something like this

func rangOfSubString(msgStr:String) ->Range<String.Index>
{

}

I hope this helps you

Reinier Melian
  • 20,519
  • 3
  • 38
  • 55