#E0143: 한 축 타입에 쓴 다축 인덱스
슬라이스가 섞인 여러 부분의 인덱스(m[1:, 0])는 축마다 인자를 하나씩 줍니다. List, Slice, 고정 배열, str은 축이 하나이므로 부분 하나만 받습니다. 슬라이스와 인덱스를 다른 괄호에 쓰거나(m[1:][0]), 축 인자를 받는 Array<T, N>(core::array::Array)에 데이터를 두세요. 직접 만든 타입은 isize와 core::index::SliceArg의 튜플에 대한 Index를 구현하면 축 인자를 받습니다.
nabi
let xs = [10, 20, 30, 40];
let y = xs[1:, 0];
error[E0143]: `List<i64>` is indexed along one axis, but this index has 2 parts with a slice among them --> main.nabi:2:9 | 2 | let y = xs[1:, 0]; | ^^^^^^^^^ | = help: slice and index in separate brackets (`m[a:b][c]`), or keep the data in an `Array` (`core::array::Array`), which takes `m[a:b, c]`
먼저 슬라이스한 뒤 그 슬라이스를 인덱싱하거나, Array를 쓰세요.
nabi
use core::array::Array;
let xs = [10, 20, 30, 40];
let y = xs[1:][0];
let m: Array<i64, 2> = [[1, 2], [3, 4]];
println(f"{y} {m[1:, 0]:?}");
20 [3]
관련 코드: E0056 잘못된 인덱싱
잘못된 곳이 있나요? GitHub에서 이 페이지 고치기. 마지막 수정