来自 Python,我喜欢 Coffeescript 从 Python 和 Perl 借用的许多特性(范围/切片、推导式、解构赋值)。Coffeescript 中是否有任何语法糖来模仿 Pythonenumerate
或zip
( itertools.izip
) 函数?
以下是我不太关心的模式:
# an enumerate call would be helpful here
i = 0
for x in arr
... use x and i ...
i++
和
# a zip would be useful here
n = Math.min(arr1.length,arr2.length)
for i in 0...n
x = arr1[i]; y = arr2[i]
... use x and y ...