+ 1
help please
Fill in the blanks to create a method that takes optional parameters and outputs the squares of its parameters: def sq( p) .each {| | puts x*x} end
1 Answer
+ 7
Is this a homework, a question from Ruby challenges, or a logic you're working on?
Anyways, I can think of 2 approaches:
â Number 1:
def sq(*p)
p.each {|x| puts x*x}
end
â Number 2:
def sq(*p)
p.each do |x|
puts x*x
end
end



