From Test-Scratch-Wiki
清单 () 的项目数 | |
清單 [ 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)
参见
- 字串长度 ()(积木), the version for 字串
Zho:变数类积木 | |
Zho:清单类积木 |
()
• 新增项目 () () • 删除第 () 项 () • 添加 () 为第 () 项 • 替换第 () 项于 () 成 () • 清单第 () 项项目 () • 清单 () 的项目数 • 清单 () 包含 () • 清单 () 显示 • 清单 () 隐藏更多积木… |