Expressions

2025/12/27

Type
Learning Resource
Format
Glossary Article
Version
General
Subject Tags
Code
Assets
All else
Copyright 2016-2026, GDQuest
Created
2026/02/16
Updated
2025/12/27

Expressions

In computer programming, an expression is any combination of special characters, variables, and function calls that is a value or produces a value.

Here are a couple of examples of expressions:

The code var health = 0 is not an expression because it does not produce a value: it creates a variable named health and assigns the value 0 to it.

You can combine expressions to form more complex expressions. For example, the expression 3 + 4 is a combination of the expressions 3 and 4 using the + operator.

In this code listing, each line contains an expression. The code uses values directly or calls functions that return values, but of course, it also works if you use variables instead of values.

3
3 + 4 * 5
"Hello, " + "world!"
true and false
randf_range(10.0, 100.0)

It's important to note that not every piece of code produces a value. For instance, defining a function or a variable is not an expression because it does not produce a value.

When you see an error like "expected expression" while coding, it means that the computer expects you to write a piece of code that produces a value but you wrote something that does not.

Become an Indie Gamedev with GDQuest!

Don't stop here. Step-by-step tutorials are fun but they only take you so far.

Try one of our proven study programs to become an independent Gamedev truly capable of realizing the games you’ve always wanted to make.

Nathan

Founder and teacher at GDQuest
  • Starter Kit
  • Learn Gamedev from Zero
Check out GDSchool

You're welcome in our little community

Get help from peers and pros on GDQuest's Discord server!

20,000 membersJoin Server

Contribute to GDQuest's Free Library

There are multiple ways you can join our effort to create free and open source gamedev resources that are accessible to everyone!