3 ms·
Isn't the "better" code wrong in the first example? instead of "result = (1...padded.size-1).map do |i|" shouldn't be "result = (1...padded.size-2).map do |i|"
by lucio 8y ago
Isn't the "better" code wrong in the first example?
instead of "result = (1...padded.size-1).map do |i|"
shouldn't be "result = (1...padded.size-2).map do |i|"?
- bhrgunatha 8y agoThere are 2 forms of range in ruby: inclusive 2 dots - 1..5 => 1, 2, 3, 4, 5 and exclusive 3 dots 1...5 => 1, 2, 3, 4 It's always felt deeply counter-intuitive to me because .. feels like it represents less than ... but that's a separate discussion.