Manasi Salvi

Understanding errors

A bit of background on this post - I am currently working on brushing up my Ruby programming knowlegde. I worked my way through the basics on Codeacademy. Codeacademy was a good way to get an intro but there is a fair bit of hand holding. So I moved on to the book ‘Learning Ruby the hard way’ by Zed A. Shaw. This book has been brilliant - there is a fair bit of hand holding initially but later on in the book as I found out you have to start building your own stuff.

This post is about my struggles with exercise 45 in the book- ‘You build a game’. I decided to build a pretty simple game incorporating the relevant components of the Ruby language and using the exercises from previous chapters as a bit og a guide. You can refer to my code here.

A continuous error I was getting whenever I ran this code was a no method error in Terminal:

 ex45-zaldo.rb:18:in `play': undefined method `next_room' for nil:NilClass (NoMethodError)

The code the line was associated with is:

class Hallway		 

	def initialize(room_map) 
		@room_map = room_map 
	end

	def play() 
		current_room = @room_map.opening_room()
		last_room = @room_map.next_room('finished')
		
	while current_room != last_room
		next_room_name = current_room.enter()
		current_room = @bone_map.next_room(next_room_name)
	end
	current_room.enter()
	end
end 

Day 180

Hello world!

I started writing code as a hobby and see what all the fuss was about. After attending a few coding events and meetups I realised there was a lot more to web development. There is so much to learn, which was both exciting and scary coming from a completely non-technical background. So it began with doing some basic courses on Codeacademy and Udemy websites to brush up on HTML, CSS and Javascript. Then I moved onto the more exciting world of Ruby and Ruby on Rails. To sum it up, this blog is simple - it is a showcase of my learnings and my portfolio.