dlang-book/book/04-массивы-ассоциативные-массивы-и-строки/src/chapter-4-2-3/app.d

15 lines
No EOL
573 B
D
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import std.stdio;
void main()
{
int[5] array = [40, 30, 20, 10, 0];
auto slice1 = array[2 .. $]; // slice1 име­ет тип int[]
assert(slice1 == [20, 10, 0]);
auto slice2 = array[]; // Та­кой же, как array[0 .. $]
assert(slice2 == array);
int[10] a;
int[] b = a[1 .. 7]; // Все в по­ряд­ке
auto c = a[1 .. 7]; // Все в по­ряд­ке, c так­же име­ет тип int[]
int[6] d = a[1 .. 7]; // Все в по­ряд­ке, срез a[1 .. 7] ско­пи­ро­ван в d
}