about define significance variable(in this situation)

Z

Zhenning Guan

def method_1(options ={})
if some_conditions
options = {:method_2 => true}
method_2(options)
end

method_3(options)
method_4(options)
end

def method_2(options ={})
# some code
end


method_1({:method_1 => true)

+++++++++++++++++++++++

in some_condition, the variable options is most significant, but we use
temporary variable name options, it would rewrite options in method_1.
what would you do to name this variable?

t_options?
temorary_options?
 
R

Robert Klemme

def method_1(options ={})
if some_conditions
options = {:method_2 => true}
method_2(options)
end

method_3(options)
method_4(options)
end

def method_2(options ={})
# some code
end


method_1({:method_1 => true)

+++++++++++++++++++++++

in some_condition, the variable options is most significant, but we use
temporary variable name options, it would rewrite options in method_1.
what would you do to name this variable?

t_options?
temorary_options?

I would not name it at all.

def method_1(options ={})
if some_conditions
method_2:)method_2 => true)
end

method_3(options)
method_4(options)
end

Btw, I have a nagging feeling that what you are doing might not be such
a good idea. But since we do not have any more context that's difficult
to substantiate.

Kind regards

robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,233
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top