请教 这段代码是什么意思

tomqyp 2007-09-23
char[] 	word;
..............
if( word[$ - 1] == '.' ) word = word[0..$ - 1];

好像是去除最后一位,能介绍下关于$符号吗
Colorful 2007-09-23
等价于
char[] word;
.............
if(word[length-1] == '.')
word = word[0..length-1];
Colorful 2007-09-23
在D语言规范的数组章节中有记载。

http://www.digitalmars.com/d/arrays.html

Array Length
Within the [ ] of a static or a dynamic array, the variable length is implicitly declared and set to the length of the array. The symbol $ can also be so used.
tomqyp 2007-09-23
谢谢
Global site tag (gtag.js) - Google Analytics