×

ruby · level 2 · unit 7 · lesson 4

  1. meet it
  2. guess first
  3. your turn
  4. fix it
  5. nailed it

Tap a green word if you get lost.

meet it

Ruby comes with a toolbox. Gems are tools others share.

You have used json already. It is part of the : tools that come with Ruby, ready for you to require. gives you Set, a collection that never holds the same item twice. gives you Date, which knows the calendar.

A is a package of Ruby code that someone else wrote and shared. On your own computer you install gems with the gem install command, then require them. Gwecode runs Ruby in your browser with no gems, so these lessons use the standard library only.

require "set"
require "date"
seen = Set.new(["fox", "owl", "fox"])
seen << "owl"
p seen.size
day = Date.new(2026, 12, 25)
puts day.strftime("%A %d %B %Y")
puts day + 7
gap = day - Date.new(2026, 12, 1)
puts gap.to_i

strftime works a bit like format, with %A for the weekday and %B for the month.