6.Splat! difference b/w passing splat and array


#1

Using splat operator:-
def what_up(greeting, *bros)
bros.each { |bro| puts "#{greeting}, #{bro}!" }
end

what_up("What up","Justin", "Ben", "Kevin Sorbo")

Instead, can't we just pass an array?What are the differences between the two?

def what_up(greeting, bros)
bros.each { |bro| puts "#{greeting}, #{bro}!" }
end

what_up("What up",[ "Justin", "Ben", "Kevin Sorbo"])


#2

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.