The code below is not working the way I’d like and I can’t figure out
why.
It returns the error “undefined local variable or method `triggers’”.
But I have defined triggers as an array. What am I not getting?
def trigger_list
triggers = Array.new
def get_triggers
puts “Please enter program that you want to trigger the power
management switch.”
triggers.push gets.chomp
puts triggers
end
get_triggers
def more_triggers
puts “Do you have other programs you want to trigger the power
management switch? [y/n]”
answer = gets.chomp.downcase
if answer == “y”
get_triggers
else
puts “Okay, triggering progams list is complete.”
end
end
more_triggers
end