Menu
CoddyTech

String

Part of the Fundamentals section of Coddy's GDScript journey. Lesson 6 of 92.

A string is a piece of text: a sequence of characters such as letters, digits, spaces and symbols. In GDScript its type is String, with a capital S.

To create a string, put the text inside double quotes or single quotes:

var s1 = "This is a string"
var s2 = 'This is also a string'

The quotes mark where the text starts and ends. They are not part of the value, so print(s1) shows This is a string.

Single quotes are handy when the text itself contains double quotes:

var line = 'She said "Hi!"'
print(line)

This prints She said "Hi!".

GDScript has no separate type for a single character: "A" is a String that is one character long.

Digits inside quotes are text too. "25" is a String, while 25 is an int.

challenge icon

Challenge

Beginner

Store the string I am learning to code with Coddy! in a variable named coddy.

Write the exact text, with the same capital letters, spaces and !. Do not change the print() line. It prints:

coddy = "I am learning to code with Coddy!"

Try it yourself

extends Node

func _ready():
	# Create the variable coddy below
	
	# Don't change the line below
	print('coddy = "', coddy, '"')
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Fundamentals

Practice on your own: Online GDScript compiler