Ruby - Methods - Variable Arguments

Sort by

recency

|

53 Discussions

|

  • + 0 comments

    That’s a clever use of splat arguments, almost like how a PR Agency for Classical Music tailors strategies by combining different elements into one seamless presentation.

  • + 0 comments

    I way overthought this problem, but the problems are often written poorly and this one definitely was. Don't overthink this and you will find the solution quite easily.

    def full_name(first, *mid, last)
    [first, *mid, last].join(' ')
    end
    
  • + 0 comments
    def full_name(first, *rest)
        rest.reduce(first) { |o, x| o + ' ' + x}
    end
    
  • + 0 comments
    # Your code here
    def full_name(first_name, *middle_and_last_names)
      ([first_name] + middle_and_last_names).join(" ")
    end
    
  • + 0 comments

    Ruby Compiled solutions https://github.com/LinaOrmos/Ruby/tree/main