2025-03-24 19:16:58 -07:00
|
|
|
# Text
|
|
|
|
|
2025-04-07 13:17:55 -07:00
|
|
|
func main()
|
2025-03-24 19:16:58 -07:00
|
|
|
|
|
|
|
# Text values are sequences of letters.
|
|
|
|
greeting := "Hello"
|
|
|
|
|
|
|
|
>> greeting.length
|
|
|
|
= ???
|
|
|
|
|
|
|
|
# Text supports interpolation with `$`:
|
|
|
|
name := "Alice"
|
2025-04-07 13:17:55 -07:00
|
|
|
message := "Hello $name, your number is $(1 + 2)!"
|
2025-03-24 19:16:58 -07:00
|
|
|
|
|
|
|
>> message
|
|
|
|
= ???
|
|
|
|
|
|
|
|
# Multi-line text uses indented quotes:
|
|
|
|
multiline := "
|
|
|
|
line one
|
|
|
|
line two
|
|
|
|
line three
|
|
|
|
"
|
|
|
|
|
2025-04-07 13:17:55 -07:00
|
|
|
# Method calls use `.`
|
|
|
|
>> multiline.lines()
|
2025-03-24 19:16:58 -07:00
|
|
|
= [???]
|
|
|
|
|
|
|
|
# Common text methods:
|
2025-04-07 13:17:55 -07:00
|
|
|
>> "hello".upper()
|
2025-03-24 19:16:58 -07:00
|
|
|
= ???
|
|
|
|
|
2025-04-07 13:17:55 -07:00
|
|
|
>> "hello world".split(" ")
|
2025-03-24 19:16:58 -07:00
|
|
|
= [???]
|