Created
May 20, 2020 15:43
-
-
Save patrickbkr/17cf890a89e42e0f1a7482528d576d9d to your computer and use it in GitHub Desktop.
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
Nice ways to construct Lists, Arrays, Maps and Hashes. | |
Is this as nice as it gets? | |
Without assignment (mostly passed or returned to/from functions): | |
| mutable | immutable | |
------------|------------------------|-------------------------------- | |
Positional | ['a', 1, 'b', 2] | ('a', 1, 'b', 2) | |
Associative | %(a=>1, b=>2) | Map.new((a=>1, b=>2)) | |
With assignment: | |
| mutable | immutable | |
------------|------------------------|-------------------------------- | |
Positional | my @x = 'a', 1, 'b', 2 | my @x := 'a', 1, 'b', 2 | |
Associative | my %x = a=>1, b=>2 | my %x := Map.new((a=>1, b=>2)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment