httpiimgurcomgzMPCu5png Consider the following methods in Ru
http://i.imgur.com/gzMPCu5.png
Consider the following methods in Ruby, what will be the values of the formal parameters after the following calls are made. list = [1, 2, 3, 4, 5] def tester(p1, p2, *p3)... end tester(\'first\', *list, \'mon\' rightarrow 72, \'tue\' rightarrow 68, \'wed\' rightarrow 59); list = [1, 2, 3, 4, 5] def tester(p1, *p2, p3)... end tester(\'first\', *list, \'mon\' rightarrow 72, \'tue\' rightarrow 68, \'wed\' rightarrow 59); list = [1, 2, 3, 4, 5] def tester(*p1, p2, p3)... end tester(\'first\', list \'mon\' rightarrow 72, \'tue\' rightarrow 68, \'wed\' rightarrow 59);Solution
Formal parameter is given in output below----->
a.
main_a.rb
list=[1,2,3,4,5]
def tester (p1,p2,*p3)
puts \"p1 is #{p1}\"
puts \"p2 is #{p2}\"
puts \"p3 is #{p3}\"
end
tester(\'first\',*list,\'mon\'=>72,\'tue\'=>68,\'wed\'=>59);
Output :
b.
main_b.rb
list=[1,2,3,4,5]
def tester (p1,*p2,p3)
puts \"p1 is #{p1}\"
puts \"p2 is #{p2}\"
puts \"p3 is #{p3}\"
end
tester(\'first\',*list,\'mon\'=>72,\'tue\'=>68,\'wed\'=>59);
Output :
c.
main_c.rb
list=[1,2,3,4,5]
def tester (*p1,p2,p3)
puts \"p1 is #{p1}\"
puts \"p2 is #{p2}\"
puts \"p3 is #{p3}\"
end
tester(\'first\',*list,\'mon\'=>72,\'tue\'=>68,\'wed\'=>59);
Output :
