Color theme
0 day streak0 XPP1
RubyLearn mode
MISSION 1 OF 1

Find a spice jar

0 XP earned
Ruby track: BeginnerMission: BeginnerHashesSymbol keysLookup defaults
Before you start this beginner track

Variables, arrays, and key-value data. Collection blocks are a step beyond basic syntax.

Guided code reading and debugging. Runnable coding challenges are available in JavaScript, Python, and SQL.

x
0 / 2 challenges
LEARN THE CONCEPT

Understand it, then try it.

A kitchen notebook stores tasting notes in a hash with symbol keys. fetch returns the value for a key, or its supplied fallback when that key is missing. Unlike assigning a missing entry, fetching does not change the notebook. length therefore still reports the original number of stored spices.

quest.rb
spices = { cumin: "warm", mint: "cool" }note = spices.fetch(:saffron, "unlisted")puts noteputs spices.length

Each mission is an independent Ruby 3 or later script. Save as quest.rb and run ruby quest.rb. All methods are built into Ruby; no gems or external data are needed.

Track the values line by line. Predict the result before running this example in your own editor.