~ casts an object to a string. Note that we are now talking about the prefix or a unary operator. If the tilde is used as an infix (see later in this chapter about what infixes are), it works as a string concatenating operator, but it still deals with strings.
my Str $a = ~42; say $a.WHAT; # (Str)
In some cases, the string context can be created implicitly, for example, when you interpolate a variable inside the double quotes.