4 ms·
// a represents a range with values 1,2,3 var a = 1...3; // b represents a range with values 1,2 var b = 1..<3; Ah! I wish they had gone for 1..3 and 1>..3
by anilgulecha 10y ago
// a represents a range with values 1,2,3
var a = 1...3;
// b represents a range with values 1,2
var b = 1..<3;
Ah! I wish they had gone for 1..3 and 1>..3 and 1..<3 and 1>..<3 to make it easy to understand. The above would map to [1,2,3], [2,3], [1,2] and [2] respectively.
Range operator quirks with ... and .. have to today be memorized and waste developer seconds that add up to man-years.
- ChristianGeek 10y agoMakes perfect sense to me...three characters define the range. Should be 1...3, 1>..3, 1..<3, and 1>.<3