Collections
Hashes
Imported from the upstream Vibescript examples at collections/hashes.vibe and runnable in the browser today.
Source
collections/hashes.vibe
# vibe: 0.2
def make_player(name, goal)
{
name: name,
goal: goal,
raised: 0,
status: "active"
}
end
def mark_complete(player)
player[:status] = "complete"
player
end
def total_with_bonus(row, bonus)
row[:raised] + bonus
end
def nested_lookup(record)
record[:meta][:tag]
end
def run
player = make_player("Alice", 1000)
completed = mark_complete(make_player("Bob", 500))
{
player: player,
completed: completed,
with_bonus: total_with_bonus({ raised: 250 }, 50),
nested: nested_lookup({ meta: { tag: "vip" } })
}
end
Output
Press run to execute run from this example.