新手问题 (100..0) 算是有效的 Range 定义吗

lilijreey · October 03, 2018 · Last by msg7086 replied at October 09, 2018 · 977 hits

求教各位大神如果 range 的左边大于右边,这种情况 step 函数如何处理。我试了一下定义是可以的,但是 step 输出不对。

你可以用

100.step by: -1, to: 0

楼上的方法可行,不过更直接的方式是 100.downto(0)

可以。你甚至可以 str[4..-4]

You need to Sign in before reply, if you don't have an account, please Sign up first.