|() = ()|
The () = () block is an Operators block and a Boolean block. The block checks if the first value is equal to the other value. If the values are equal, the block returns true; if not, false. This block is not case-sensitive.
In Scratch 1.3 and before, it only accepted numbers as values.
If an action must be performed if a variable equals certain amount, this block can be used.
Some common uses for the () = () block:
- Pausing a script until a variable reaches a certain amount
when flag clicked wait until <(score) = > say [Good job!]
- Checking answers imputed with the Ask () and Wait block
when green flag clicked ask [Was my joke funny?] and wait if <(answer) = [yes]> then say [Thank you!] for (2) secs end
- Checking if boolean values are the same:
when gf clicked if <<mouse down?> = <touching [sprite 1 v]?>> then //fast way say [Either you are clicking and I am on sprite 1, or you are not clicking and I am not on sprite 1.] end if <<<mouse down?> and <touching [sprite 1 v]?>> or <not <<mouse down?> or <touching [sprite 1 v]>>>> then //Harder way say [Either you are clicking and I am on sprite 1, or you are not clicking and I am not on sprite 1.] end
- Comparing different values
if <(x position) = (size)> then say [The sprite size and x position are equal.] for (5) secs else say [The sprite size and x position are not equal.] for (5) secs end
- Doing something when there are 0 lives left
when green flag clicked forever if <(lives) = > then say [uh oh...] end
- Main article: List of Block Workarounds
The block can be replicated with the following code:
<not <<(a) > (b)> or <(a) < (b)>>>
The following also works:
delete (all v) of [list v] add (a) to [list v] if <[list v] contains (b)> then set [result v] to [true] else set [result v] to [false] end