F
Frodo Larik
Hi all,
I have two questions regarding object methods
1. Is it possible to call a method from a variable?
Something like this:
i_am_just_a_var = 'this_is_the_real_method'
o = Object.new
o.#{i_am_just_a_var} = 'some thing I want'
2. What is the best way to check for a method of an object?
After playing around in irb I came up with this:
o = Object.new
if ( o.methods.grep(/^some_method_name$/ )
# do stuff
else
# do something else
end
Sincerely,
Frodo Larik
I have two questions regarding object methods
1. Is it possible to call a method from a variable?
Something like this:
i_am_just_a_var = 'this_is_the_real_method'
o = Object.new
o.#{i_am_just_a_var} = 'some thing I want'
2. What is the best way to check for a method of an object?
After playing around in irb I came up with this:
o = Object.new
if ( o.methods.grep(/^some_method_name$/ )
# do stuff
else
# do something else
end
Sincerely,
Frodo Larik