From Test-Scratch-Wiki

Translate: - English - 中文 
清单 () 的项目数
清單 [ v] 的項目數
类别 清单类积木
形狀 椭圆形积木
加入於 1.3

The Length of () 积木 is a 清单类积木 and a 椭圆形积木. The block reports how many 项目s a 清单 contains.

用法示例

In certain 专案, different events can happen based on the length of a value; this block can be used here.

Some common uses for the Length of () block:

  • Checking the number of items a player has obtained
說出 (字串組合 [You have ] 和 (字串組合 (清單 [list v] 的項目數 :: list) 和 [ items.]))
  • Iterating through a list by repeating the length amount of times.
重複 (清單 [list v] 的項目數 :: list) 次 
  變數 [i v] 改變 (1)
  說出 (清單第 (i) 項項目\( [list v] \) :: list) (2) 秒
end
  • Accessing the second last, for example, item of a list
(清單第 ((length of [list v] :: list) - (2)) 項項目\( [list v] \) :: list)

参见