小编Kir*_*nap的帖子

朱莉娅意外的元组迭代?

我想迭代一个元组中的三元组,发现Julia中的一个奇怪的逗号细节是我们应该期待的吗?

julia> for (k, n, d) in (("x1", "x2", "x3"),); @show k, n, d; end;
(k, n, d) = ("x1", "x2", "x3")    
# However if I remove , it doesn't work
julia> for (k, n, d) in (("x1", "x2", "x3")); @show k, n, d; end;
ERROR: BoundsError
Stacktrace:
[1] indexed_next(::String, ::Int64, ::Int64) at ./tuple.jl:56
[2] anonymous at ./<missing>:?
Run Code Online (Sandbox Code Playgroud)

iteration tuples julia

1
推荐指数
1
解决办法
82
查看次数

标签 统计

iteration ×1

julia ×1

tuples ×1