logo
  • 教程列表
  • SO官方文檔
  • 範圍
    • 字串和陣列是範圍
    • 建立一個新的輸入範圍型別
  1. StackOverflow 文件
  2. D Language 教程
  3. 範圍
  4. 字串和陣列是範圍

字串和陣列是範圍

Created: November-22, 2018

import std.stdio;

void main() {
    auto s = "hello world";
    auto a = [1, 2, 3, 4];

    foreach (c; s) {
        write(c, "!"); // h!e!l!l!o! !w!o!r!l!d!
    }
    writeln();

    foreach (x; a) {
        write(x * x, ", "); // 1, 4, 9, 16, 
    }
}
  • 建立一個新的輸入範圍型別
  • 範圍

Copyright © 2018. All right reserved

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

  • 關於本站
  • 免責聲明