advertisement

Article:
  Strings in Cocoa: Part I
Subject:   is {49,50} really the last half?
Date:   2004-10-25 09:38:36
From:   Valennad
Once more!


The way ranges work is like this: If we had a string with 100 characters (elements), then the range {49, 50} specifies a substring whose first element is the 49th character of the parent string, and includes the following 50 elements -- that is, the last half of the parent string (remember, strings are arrays in their most fundamental form, and counting always starts from 0).


Is it really so? We have 100 elements numbered from 0 to 99. Therefore the first half of the parent string must be from 0 to 49 or {0,50} and the last half - from 50 to 99 or {50,50} (but not {49,50}!!!).


Isn't it?