Created
August 19, 2022 18:08
-
-
Save midwire/996fa6e23cd9c57b99a877f37de4af3f to your computer and use it in GitHub Desktop.
[Ruby Splat and Double-Splat] #ruby
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def foo(a, *b, **c) | |
[a, b, c] | |
end | |
> foo 10 | |
=> [10, [], {}] | |
> foo 10, 20, 30 | |
=> [10, [20, 30], {}] | |
> foo 10, 20, 30, d: 40, e: 50 | |
=> [10, [20, 30], {:d=>40, :e=>50}] | |
> foo 10, d: 40, e: 50 | |
=> [10, [], {:d=>40, :e=>50}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment