What are assertions?

Assertions are like checkpoints that make sure everything is going as it should while you're playing a game.

Imagine you’re building a tower with blocks. Every time you add a new block, you check if it's steady and fits the pattern you’ve chosen. If it’s not, you know something went wrong, maybe the block was placed incorrectly or it’s the wrong shape.

Like a Special Helper

Think of an assertion as a special helper who checks your work as you go along. For example, if you’re writing a story and you say "The cat is black," the helper will make sure that stays true, if later in the story the cat turns white, the helper will point it out.

What Happens If It Fails?

If an assertion finds a mistake, it’s like getting a red flag in your game. You know you need to go back and fix something before moving forward. This helps you catch mistakes early and keep your game, or your story, from getting confusing.

Assertions are just simple checks that help you stay on track, one step at a time!

Take the quiz →

Examples

  1. A child says, 'I am hungry.' This is an assertion because it expresses a belief about the current state of the world.
  2. If you say, 'It is raining outside,' that's an assertion, a simple statement of fact.
  3. When someone claims, 'The moon is made of cheese,' they're making an assertion, even if it’s not true.

Ask a question

See also

Discussion

Recent activity

Categories: Science · logic· programming· statements