logo
  • 教程列表
  • SO官方文档
  • 动态数组和切片
    • 数组操作
    • 声明和初始化
    • 片
  1. StackOverflow 文档
  2. D Language 教程
  3. 动态数组和切片
  4. 片

片

Created: November-22, 2018

import std.stdio;

void main() {
    int[] arr = [1, 2, 3, 4, 5];
 
    auto arr2 = arr[1..$ - 1]; // .. is the slice syntax, $ represents the length of the array
    writeln(arr2); // [2, 3, 4]

    arr2[0] = 42;
    writeln(arr[1]); // 42
}
  • 声明和初始化

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 关于我们
  • 免责声明