Ruby: undefined method `include?' for nil:NilClass (NoMethodError) -


i can't find proper fix delete conditional expression error, 'include?'

when "delete"   puts "please type verbatim task delete:"   target_task = gets.chomp   if @all_tasks.include?("target_task")     @all_tasks.delete("target_task")     puts "#{target_task} removed list"   end 

full code linked here @ github. line 70.

i've tried proper include? format linked here, tried every combination of parenthesis , quotations target_task, , tried including my_list.@all_tasks.include? too. no dice.

the problem @all_tasks instance variable of list class , try access outside class. that, add

attr_reader :all_tasks 

inside definition of list class , call

if my_list.all_tasks.include?("target_task") 

instead.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -