Working on a to do list project. Could someone tell me why the after I
add a task in case ‘1’ when I display the list using option ‘2’ it
prints out something like #Task:0x27eaff0?
Here is my code:
module Menu
def menu
“Welcome to the To Done list of the future!
Enter 1 to add a task
Enter 2 to show tasks
Enter Q to quit\n”
end
def show
menu
end
end
module Promtable
def prompt(message = “Well get to it then”, symbol = “:>”)
print message
print symbol
gets.chomp
end
end
class List
attr_reader :all_tasks
def initialize
@all_tasks = []
end
def add(task)
all_tasks << task
end
def show
all_tasks
end
end
class Task
attr_reader :desc
def initialize(desc)
@desc = desc
end
end
if FILE == $PROGRAM_NAME
include Menu
include Promtable
my_list = List.new
until [‘q’].include?(user_input = prompt(show).downcase)
case user_input
when ‘1’
my_list.add(Task.new(prompt(“What do you want to add?”)))
when ‘2’ then puts my_list.show
else puts “That doesn’t work here buddy\n”
end
end
puts “Peace Out”
end