Fork

CONDITIONAL / BRANCHING — *chooses a path based on what's true right now.*

Loading audio…

Press play to listen along. The line being read lights up as you go.

Show full transcript

Loading transcript…

01 Opening
Fork beat 1 of 5

Fork wasn't a fluffy squirrel or a talking badger. Fork was, well, a fork — not the dinner kind, but a small painted wooden sign, the sort you'd see on a tiny path. Above it floated a little diamond shape with the word IF inside, and two arrows pointed away from the diamond: one left, one right.

"Alright, team! Meet Fork!" Loop clapped her hands — Loop always sounded excited. "Fork helps us make choices. Not Fork's choices, mind you. Our choices. Or really, the program's choices." I looked at Fork. It just sat there, not deciding anything. "See the diamond?" Loop asked. "It holds a question — a condition. If the answer is YES, we go one way. If it's NO, we go the other."

02 Fork
Fork beat 2 of 5

"Let's say we want a super-sparkle from the Sparkle Collector," Loop said, patting the big clunky contraption that usually just coughed out regular sparkles. "The machine's picky. It only gives a super-sparkle if you already have exactly five regular sparkles." She pointed at Fork's diamond. "So the question in here is: Do we have five sparkles?"

She traced the left arrow. "If the answer is YES — this way. The program tells the machine: super-sparkle, please. Hooray!" Then the right arrow. "If NO — that way. Go find more sparkles. Boo."

"So Fork doesn't decide?" I asked. "It just shows the paths?"

"Exactly! Fork is a branch-point, not a decision-maker. The condition makes the decision. Condition true, branch one way. Condition false, branch the other."

03 Fork
Fork beat 3 of 5

"Conditions are like yes-or-no questions," Loop went on. "They're either TRUE or FALSE. No 'maybe' allowed in code — it's super strict. 'Is the sky blue?' TRUE. 'Are pigs flying right now?' FALSE — unless you know something I don't." I giggled. "So a condition is just a fact we check. We can ask if two things are the same with two equals signs: ==. Is sparkles == 5? We ask if they're not the same with !=. Is machine != broken?" She was on a roll. "We can ask if one thing's bigger or smaller> and <. Is your_age > 9? Is shoe_size < 12? Every one of these gives back a TRUE or a FALSE. That's all a condition ever does."

04 Fork
Fork beat 4 of 5

"What if we need to ask two questions at once?" I wondered.

"Great thinking! We combine conditions with AND and OR." Loop nodded at the machine. "Maybe it only works if you have five sparkles AND the machine is switched on. For an AND, both must be true — one false, and you branch the other way. For an OR, only one needs to be true: 'five sparkles OR it's your birthday' gets you the super-sparkle either way." She grinned. "Verity, over in DiscreteQuest, taught us all about AND and OR — she says they're the building blocks of good thinking. And here's the wild part: the true path can hold another Fork inside it. That's called nesting — a choice that leads to another choice, like a tree of paths. If seven days each need a different path, we could stack 'if... else if... else if...' — but there's a tidier way called a match or switch statement, a neat little menu you pick from. Loop loves tidy code."

05 Closing
Fork beat 5 of 5

"Does Fork know the answer ahead of time?" I asked. "Like, whether I have five sparkles before I even get there?"

"Nope — and that's the clever part," Loop said, tapping the diamond. "The condition is checked right when you need it. Not decided in advance. It depends on what's true right now. Different inputs, different paths — that's the whole magic of branching. So remember: Fork is the conditional. If a thing is true, go this way; if not, go that way. Fork's a branch-point, not a decision-maker. It's not hard — true, this way; false, that way."

I looked at Fork's two arrows one more time, and something in my chest went quiet and easy. All those choices that used to make me feel wobbly and stuck — they were just a question with a yes and a no. I felt lighter, like I could stand at a fork in the path now and not be scared of it. Just check the condition. Then go.

The CodeRealm ensemble

Fork is part of CodeRealm's distributed-narrative cast. Each character embodies a different curricular primitive; together they teach the full subject.

Kids also liked