zip()函數(shù)將多個(gè)列表值轉(zhuǎn)成一個(gè)多維的列表:
>> zip(1px 2px 3px,solid dashed dotted,green blue red) ((1px "solid" #008000), (2px "dashed" #0000ff), (3px "dotted" #ff0000))
在使用zip()函數(shù)時(shí),每個(gè)單一的列表個(gè)數(shù)值必須是相同的:
>> zip(1px 2px 3px, solid , green blue red) NoMethodError: undefined method `options=' for nil:NilClass Use --trace for backtrace.
否則將會(huì)出錯(cuò)。
zip()函數(shù)中每個(gè)單一列表的值對(duì)應(yīng)的取其相同位置值:
|--- List ---|--- nth(1) ---|--- nth(2) ---|--- nth(3) ---|
|------------|--------------|--------------|--------------|
| List1 | 1px | 2px | 3px |
|------------|--------------|--------------|--------------|
| List2 | solid | dashed | dotted |
|------------|--------------|--------------|--------------|
| List3 | green | blue | red |
|------------|--------------|--------------|--------------|
zip()函數(shù)組合出來就成了:
1px solid green, 2px dashed blue, 3px dotted red
你可以寫出下面函數(shù)運(yùn)行出的結(jié)果嗎?
請(qǐng)驗(yàn)證,完成請(qǐng)求
由于請(qǐng)求次數(shù)過多,請(qǐng)先驗(yàn)證,完成再次請(qǐng)求
打開微信掃碼自動(dòng)綁定
綁定后可得到
使用 Ctrl+D 可將課程添加到書簽
舉報(bào)