Ruby Final Project - Step 5

Hi All

Having difficulty with step 5 of the Ruby Final Project. After getting repeated error messages with my own code, I gave in and copied out the solution code verbatim but still seem to be hitting a brick wall.

So code is entered as:

class List
	attr_reader :all_tasks
		my_list =
		puts "You have created a new list"
		my_list.add("Learn Ruby"))
		puts "You have added a task to the ToDo List"
	def initialize
		@all_tasks = []
	def add(task)
		all_tasks << task
class Task
	attr_reader :description
	def initialize(description)
	    @description = description

and when running I receive the following error message:

➜my_final_Ruby_project** ruby todo.rb
You have created a new list
odo.rb:6:in `&lt;class:List&gt;': uninitialized constant List::Task (NameError)
from todo.rb:1:in `&lt;main&gt;'

From research online I can see that Uninitialized Constant is a fairly common fault but I’m not sure what’s causing it.

Could some kind soul explain where I’m going wrong?

1 Like

You might want to define your classes before you start executing them.

1 Like

Had a feeling it would be something simple I’d missed. Cheers!

1 Like