Archive.png This article or section documents something not included in the current version of Scratch (3.0). It is only useful from a historical perspective.
This article or section documents an outdated version of Scratch (version 1.4). For this article in Scratch 2.0, see Casting (2.0).

Casting is the conversion of data types for compatibility within methods. For example, a list is cast to a string whenever it is used as a string input. So joining a list [a, b, c] to "... is a list" will return the string "a b c ... is a list".

Rules

Casting in Scratch follows the following rules:

Casting Rules String input Number input
Strings String:
"abc"
"abc" 0
String:
"123"
"123" 123
Numbers Number:
123
"123" 123
Booleans Boolean:
true
"true". You cannot insert booleans in number inserters, but as per some modifications of Scratch, 1. Most modifications, however, cast to 0.
Boolean:
false
"false". You cannot insert booleans in number inserters, but as per some modifications of Scratch, 0.
Lists List:
["a", "b", "c"]
"abc" 0
List:
["a", "b", "c", "are the letters"]
"a b c are the letters" 0
List:
[1, 2, 3]
"123" 123
List:
[1, 22, 3]
"1 22 3" 1
List:
[3, ".", 1, 4]
"3.14" 3.14
List:
[]
"" 0