Permalink
Browse files

Implement QAST::Node.annotate_self

Same as .annotate but return self instead of the value we're
annotating with. Makes it easier to set annotations when you just
wanna set them and return the Node; no need to save it into variable.
  • Loading branch information...
zoffixznet committed Jan 15, 2018
1 parent 88fbd34 commit 4e647a70b7e549423ea2fa47e5da51ea8d283d69
Showing with 5 additions and 0 deletions.
  1. +5 −0 src/QAST/Node.nqp
@@ -87,6 +87,11 @@ class QAST::Node {
%!annotations := nqp::hash() unless nqp::ishash(%!annotations);
%!annotations{$key} := $value;
}
method annotate_self(str $key, $value) {
%!annotations := nqp::hash() unless nqp::ishash(%!annotations);
%!annotations{$key} := $value;
self
}

method ann(str $key) {
nqp::ishash(%!annotations)

0 comments on commit 4e647a7

Please sign in to comment.