Skip to content

Instantly share code, notes, and snippets.

@Summertime

Summertime/hm.p6 Secret

Last active March 7, 2019 08:24
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 Summertime/15b1bde655a3fa01acf8eccc35e01c37 to your computer and use it in GitHub Desktop.
Save Summertime/15b1bde655a3fa01acf8eccc35e01c37 to your computer and use it in GitHub Desktop.
multi sub trait_mod:<is>(Sub $s, :@in){
@in.append($s);
say @in; # roughly [something]
}
my @funcs = [];
sub something is in(@funcs) { 1; }
say @funcs; # []
# desired effect in python
funcs = []
def add_to(listy):
def _add_to(func):
listy.append(func)
return func
return _add_to
@add_to(funcs)
def funcy():
return 1
print(funcs) # [funcy]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment