我期待下面的代码打印chr7
。
import strutils
var splitLine = "chr7 127471196 127472363 Pos1 0 +".split()
var chrom, startPos, endPos = splitLine[0..2]
echo chrom
相反,它打印@[chr7, 127471196, 127472363]
.
有没有办法同时从序列中解压缩多个值?
如果元素不连续,那么执行上述操作的最简单方法是什么?例如:
var chrom, startPos, strand = splitLine[0..1, 5]
给出错误:
read_bed.nim(8, 40) Error: type mismatch: got (seq[string], Slice[system.int], int literal(5))
but expected one of:
system.[](a: array[Idx, T], x: Slice[system.int])
system.[](s: string, x: Slice[system.int])
system.[](a: array[Idx, T], x: Slice[[].Idx])
system.[](s: seq[T], x: Slice[system.int])
var chrom, startPos, strand = splitLine[0..1, 5]
^