Skip to main content
added 14 characters in body; added 35 characters in body
Source Link
Vatsal
  • 18.3k
  • 11
  • 48
  • 83

To simply answer your ending question: this is not a bug. This is normal behavior.

String.CharacterView.Index can never exceed the endIndex of the parent construct (i.e. the character view), and thus triggers a runtime error when forced to (as correctly noted in the latter part of your answer). This is by design.

The only solution is to write your own alternative to the stride(to:by:), one that avoids equalling or exceeding the endIndex in any way.

As you know already, you can technically implement Strideable, but you cannot prevent that error. And since stride(to:by:) is not declaredblueprinted within the protocol itself but introduced in an extension, there is no way you can use a "custom" stride(to:by:) in a generic scope (i.e. <T: Strideable> etc.). Which means you should probably not try and implement it unless you are absolutely sure that there is no way that error can occur; something which seems impossible.

Solution: There isn't one, currently. However, if you feel that this is an issue, I encourage you to start a thread in the swift-evolution mailing list, where this topic would be best received.

To simply answer your ending question: this is not a bug. This is normal behavior.

String.CharacterView.Index can never exceed the endIndex of the parent construct (i.e. the character view), and thus triggers a runtime error when forced to (as correctly noted in the latter part of your answer). This is by design.

The only solution is to write your own alternative to the stride(to:by:), one that avoids equalling or exceeding the endIndex in any way.

As you know already, you can technically implement Strideable, but you cannot prevent that error. And since stride(to:by:) is not declared within the protocol itself but in an extension, there is no way you can use a "custom" stride(to:by:) in a generic scope (i.e. <T: Strideable> etc.). Which means you should probably not try and implement it unless you are absolutely sure that there is no way that error can occur; something which seems impossible.

Solution: There isn't one, currently. However, I encourage you to start a thread in the swift-evolution mailing list, where this topic would be best received.

To simply answer your ending question: this is not a bug. This is normal behavior.

String.CharacterView.Index can never exceed the endIndex of the parent construct (i.e. the character view), and thus triggers a runtime error when forced to (as correctly noted in the latter part of your answer). This is by design.

The only solution is to write your own alternative to the stride(to:by:), one that avoids equalling or exceeding the endIndex in any way.

As you know already, you can technically implement Strideable, but you cannot prevent that error. And since stride(to:by:) is not blueprinted within the protocol itself but introduced in an extension, there is no way you can use a "custom" stride(to:by:) in a generic scope (i.e. <T: Strideable> etc.). Which means you should probably not try and implement it unless you are absolutely sure that there is no way that error can occur; something which seems impossible.

Solution: There isn't one, currently. However, if you feel that this is an issue, I encourage you to start a thread in the swift-evolution mailing list, where this topic would be best received.

added 427 characters in body
Source Link
Vatsal
  • 18.3k
  • 11
  • 48
  • 83

ThisTo simply answer your ending question: this is not a bug. This isis normal behavior.

String.CharacterView.Index can never exceed the endIndex of the parent construct (i.e. the character view), and thus triggers a runtime error when forced to (as correctly noted in the latter part of your answer). This is by design.

The only solution is to write your own alternative to the stride(to:by:), one that avoids equalling or exceeding the endIndex in any way. You can

As you know already, you can technically implement Strideable, but you cannotcannot prevent that error. And since stride(to:by:) is not declared within the protocol itself but in an extension, there is no way you can use a "custom" stride(to:by:) in a generic scope (i.e. <T: Strideable> etc.). Which means you should probably not try and implement it unless you are absolutely sure that there is no way that error can occur; something which seems impossible.

Solution: There isn't one, currently. However, I encourage you to start a thread in the swift-evolution mailing list, where this topic would be best received.

This is not a bug. This is normal behavior.

String.CharacterView.Index can never exceed the endIndex of the parent construct (i.e. the character view), and thus triggers a runtime error when forced to (as correctly noted in the latter part of your answer). This is by design.

The only solution is to write your own alternative to the stride(to:by:), one that avoids equalling or exceeding the endIndex in any way. You can technically implement Strideable, but you cannot prevent that error. And since stride(to:by:) is not declared within the protocol itself but in an extension, there is no way you can use a "custom" stride(to:by:) in a generic scope (i.e. <T: Strideable> etc.).

To simply answer your ending question: this is not a bug. This is normal behavior.

String.CharacterView.Index can never exceed the endIndex of the parent construct (i.e. the character view), and thus triggers a runtime error when forced to (as correctly noted in the latter part of your answer). This is by design.

The only solution is to write your own alternative to the stride(to:by:), one that avoids equalling or exceeding the endIndex in any way.

As you know already, you can technically implement Strideable, but you cannot prevent that error. And since stride(to:by:) is not declared within the protocol itself but in an extension, there is no way you can use a "custom" stride(to:by:) in a generic scope (i.e. <T: Strideable> etc.). Which means you should probably not try and implement it unless you are absolutely sure that there is no way that error can occur; something which seems impossible.

Solution: There isn't one, currently. However, I encourage you to start a thread in the swift-evolution mailing list, where this topic would be best received.

added 275 characters in body
Source Link
Vatsal
  • 18.3k
  • 11
  • 48
  • 83

This is not a bug. This is normal behavior.

String.CharacterView.Index can never exceed the endIndex of the parent construct (i.e. the character view), and thus triggers a runtime error when forced to (as you correctly noted in the latter part of your answer). This is by design.

The only solution is to write your own alternative to the stride(to:by:), one that avoids equalling or exceeding the endIndex in any way. You can technically implement Strideable, but you cannot prevent that error. And since stride(to:by:) is not declared within the protocol itself but in an extension, there is no way you can use a "custom" stride(to:by:) in a generic scope (i.e. <T: Strideable> etc.).

This is not a bug. This is normal behavior.

String.CharacterView.Index can never exceed the endIndex of the parent construct (i.e. the character view), and thus triggers a runtime error when forced to (as you correctly noted in the latter part of your answer). This is by design.

The only solution is to write your own alternative to the stride(to:by:), one that avoids equalling or exceeding the endIndex in any way.

This is not a bug. This is normal behavior.

String.CharacterView.Index can never exceed the endIndex of the parent construct (i.e. the character view), and thus triggers a runtime error when forced to (as correctly noted in the latter part of your answer). This is by design.

The only solution is to write your own alternative to the stride(to:by:), one that avoids equalling or exceeding the endIndex in any way. You can technically implement Strideable, but you cannot prevent that error. And since stride(to:by:) is not declared within the protocol itself but in an extension, there is no way you can use a "custom" stride(to:by:) in a generic scope (i.e. <T: Strideable> etc.).

added 34 characters in body
Source Link
Vatsal
  • 18.3k
  • 11
  • 48
  • 83
Loading
Source Link
Vatsal
  • 18.3k
  • 11
  • 48
  • 83
Loading