DEV Community

n350071🇯🇵
n350071🇯🇵

Posted on

1

Ruby array multiple assignment

Assignment to variables

a, b = [:hello, :world]
puts a #=> :hello
puts b #=> :world
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

🔗 Parent Note

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay