In the code below:
module UserInterface
@main_menu_options = { 1 => "Display Task List", 2 => "Add New Task", 3 => "Edit A Task", 4 => "Delete A Task", "Q" => "Quit" }
def main_menu(string="")
@main_menu_options.each_value { |v| puts v }
if @main_menu_options == nil then puts "NOTHING THERE" end
end
end
I've created a module variable and put a standard Ruby hash inside it.
But the first line of the main_menu method can't display the values.
When I comment out the first line of that method, the second line always displays "NOTHING THERE", which tells me that the method thinks the class variable contains nil.
I also tried recreating that exact same hash in the method body, and that line of code could display its values perfectly fine, so I don't see how it can be the statement in the method. I think the problem must be the module class variable.
Why does that module method think there's nothing in my @main_menu_options module class variable when it clearly has something in it?