DEV Community 👩‍💻👨‍💻

n350071🇯🇵
n350071🇯🇵

Posted on

Ruby array multiple assignment

Assignment to variables

a, b = [:hello, :world]
puts a #=> :hello
puts b #=> :world

Assignment as arguments ( 2 Ways )

def show_two_arguments(a,b:)
  puts a
  puts b
end

show_two_arguments(:hello, b: :world)
#=> :hello
#=> :world

show_two_arguments(*[:hello, b: :world])
#=> :hello
#=> :world

🔗 Parent Note

Top comments (0)

All DEV content is created by the community!

Hey, if you're landing here for the first time, you should know that this website is a global community of folks who blog about their experiences to help folks like you out.

Sign up now if you're curious. It's free!