daily pastebin goal
18%
SHARE
TWEET

[Perl 6] Creating and removing elements from sets.

cwchen Nov 8th, 2017 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. my $set = (1, 2, 3).SetHash;
  2. $set.elems == 3 or die "Wrong element count";
  3.  
  4. # Add a new element.
  5. $set{4} = True;
  6. $set.elems == 4 or die "Wrong element count";
  7.  
  8. # Add a duplicated element, no effect.
  9. $set{3} = True;
  10. $set.elems == 4 or die "Wrong element count";
  11.  
  12. # Remove an element.
  13. $set{1} = False;
  14. $set.elems == 3 or die "Wrong element count";
  15.  
  16. # Remove a non-existing element, no effect.
  17. $set{1} = False;
  18. $set.elems == 3 or die "Wrong element count";
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top