Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

http://i.imgur.com/gzMPCu5.png Consider the following methods in Ruby, what will

ID: 3939169 • Letter: H

Question

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);

Explanation / Answer

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 :