I'm working through "Learn Ruby The Hard Way", and have a question about calling a method inside an object. I'm hoping someone can shed some light on this.
The code is:
def play()
next_room = @start
while true
puts "\n--------"
room = method(next_room)
next_room = room.call()
end
end
I know that the while loop in this method is what makes the game continue on to its different areas. My question is, why does room.call() have to first be passed to next_room for it to work? Why doesn't just doing room.call() make the game continue to the next area?
I tested this out myself and I don't understand why it won't work this way.