Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patrickbkr/17cf890a89e42e0f1a7482528d576d9d to your computer and use it in GitHub Desktop.
Save patrickbkr/17cf890a89e42e0f1a7482528d576d9d to your computer and use it in GitHub Desktop.
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