J
James Byrne
I clearly have either forgotten something important, or I never
understood it correctly, but I cannot sort out what is wrong with the
following:
module AO_Map
. . .
def ao_map_module_method( y )
puts( current_batch.to_yaml )
. .
end
class Main
. .
require file_dir + "/ao_map"
include AO_Map
. .
attr_accessor( :current_batch )
. .
def execute
. . .
current_batch = other_class_main_method( x ) # is a hash
. . .
if current_batch
begin
. . .
ao_map_module_method( y )
. . .
end
This construct fails in ao_map_module_method with current_batch being
nil. Why? What is it that I am not comprehending about variable scope
in attempting to do this?
I know that I can pass current_batch in as a method parameter to
ao_map_module_method but what is wrong with simply calling an accessor
method from inside another method? Presumably current_batch and
ao_map_module_method are at the same level inside of class Main.
understood it correctly, but I cannot sort out what is wrong with the
following:
module AO_Map
. . .
def ao_map_module_method( y )
puts( current_batch.to_yaml )
. .
end
class Main
. .
require file_dir + "/ao_map"
include AO_Map
. .
attr_accessor( :current_batch )
. .
def execute
. . .
current_batch = other_class_main_method( x ) # is a hash
. . .
if current_batch
begin
. . .
ao_map_module_method( y )
. . .
end
This construct fails in ao_map_module_method with current_batch being
nil. Why? What is it that I am not comprehending about variable scope
in attempting to do this?
I know that I can pass current_batch in as a method parameter to
ao_map_module_method but what is wrong with simply calling an accessor
method from inside another method? Presumably current_batch and
ao_map_module_method are at the same level inside of class Main.