Skip to content

Instantly share code, notes, and snippets.

@colomon
Last active December 18, 2015 04:09
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 colomon/5723570 to your computer and use it in GitHub Desktop.
Save colomon/5723570 to your computer and use it in GitHub Desktop.
Thinking out loud about set & bag construction
set (1, 2, 3) ==> set(1, 2, 3)
set [1, 2, 3] ==> set([1, 2, 3])
my @a = 1, 2, 3;
set @a ==> set(1, 2, 3)
set { a=>1, b=>2 } ==> set({ a=>1, b=>2 })
my %h = a=>1, b=>2;
set %h ==> set(a=>1, b=>2)
{ a=>1, b=>2 }.Set ==> set(a, b)
%h.Set ==> set(a, b)
(a=>2).Set ==> set(a)
(a=>False).Set ==> set()
(a, b, c).Set ==> set(a, b, c)
a.Set ==> set(a)
@a.Set ==> set(1, 2, 3)
bag (1, 2, 3) ==> bag(1 => 1, 2 => 1, 3 => 1)
bag (1, 1, 1, 2) ==> bag(1 => 3, 2 => 1)
bag %h ==> bag( (a=>1)=>1, (b=>2)=>1 )
bag { a=>1, b=>2 } ==> bag({ a=>1, b=>2 } => 1)
{ a=>1, b=>2 }.Bag ==> bag("a" => 1, "b" => 2)
(a=>2).Bag ==> bag("a" => 2)
(a=>1, b=>2).Bag ==> bag("a" => 1, "b" => 2)
a.Bag ==> bag("a" => 1)
bag a=>1, b=>2 ==> 2 unexpected named parameters passed (a, b), perhaps you wanted .Bag ?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment