From Test-Scratch-Wiki
- The correct title of this article is () > () (block). The change of name is due to technical restrictions.
() > () | |
() > () | |
类别 | 运算类积木 |
形狀 | 菱形积木 |
The () > () 积木 is an 运算类积木 and a 菱形积木. The block checks if the first value is greater than the other value. If the second value is less, the block returns true; if not, it returns false.
This block works with letters too, not just numbers. In Scratch, letters at the top of the alphabet (e.g. a, b, c) are worth less than letters at the end (e.g. x, y, z). Other rules of alphabetical order apply (e.g. zach > az). In Scratch 1.3 and previous versions, it only accepted numbers.
用法示例
If a group must be arranged in size, this block can easily do the job.
Some common uses for the () > () block are below:
- Arranging a set of numbers/letters
如果 <(a) > (b)> 那麼 說出 (字串組合 (b) 和 (字串組合 [, ] 和 (a))) (2) 秒 否則 說出 (字串組合 (a) 和 (字串組合 [, ] 和 (b))) (2) 秒 end
- Evaluating numbers/letters
重複直到 <((a) + (b)) > (repcount)> 說出 (字串組合 [Checking i = ] 和 (repcount)) (2) 秒 變數 [repcount v] 改變 (1) end 說出 (字串組合 [The answer is ] 和 ((repcount) - (1)))
- Comparing different 变量s (e.g. comparing two characters' health in a game)
如果 <(score1) > (score2)> 那麼 說出 [Gotcha!] (2) 秒 end
- Cloud highscores (used by many)
如果 <(Score) > (☁ Highscore)> 那麼 變數 [☁ Highscore v] 設為 (Score) end
应用
- Main article: List of Block Workarounds
The block can be replicated with the following code:
<<<(a) < (b)> 或 <(a) = (b)>> 不成立>
参见
() + ()
• () - () • () * () • () / () • 随机取数 () 到 () • () < () • () = () • () > () • () 且 () • () 或 () • () 不成立 • 字串组合 () 和 () • 字串中第 () 字 () • 字串长度 () • ) 除 () 的馀数 • 四舍五入数值 () • () 数值 ()更多积木… |