1, string, which is similar to a character array
2. About [M. N] and [M... n]
ClassTestruby <test: Unit: testcase
Atog = ['A', 'B', 'C', 'D', 'E', 'F', 'G']
DefTest_sub_array
Assert atog [2,4]. Length =4
End
DefTest_sub_array_close
Assert atog [2..4]. Length =3
End
DefTest_sub_array_open
Assert atog [2...4]. Length =2
End
End
The ruby language also hinders productivity, although small;
1. Can you remember [M .. n] and [M .. n] which include N and which does not include n?
2. Are you sure you don't shake your hands when coding? Are you sure you have the wrong decimal point?
Of course, there are not many areas in the array range, or you have a unit test to escort, basically there is no impact
But I always think it can provide more obvious methods.
1. For example, the differences between [M.. N), [M. N], (M. N], and so on are not obvious.
2. Only one of them is supported. To express another meaning, you only need to add or subtract 1 when passing the parameter n.
Avoid it as much as possible in the future