...

/

Solution: Interactive Fiction Display

Solution: Interactive Fiction Display

Understand the solution to the “Interactive Fiction Display” challenge.

We'll cover the following...

Solution

Let's execute the following solution code and see how it works.

def describe (cell)
if cell.links.count == 1
return "This is a dead-end."
elsif cell.links.empty?
return "There are no exits from this room"
end
%i( north south east west ).each do |direction|
if cell.linked?(cell.send(direction))
return "A passage goes #{direction}"
end
end
puts
end
...