diff options
author | Adam <adam@adambard.com> | 2016-01-08 14:35:53 +0800 |
---|---|---|
committer | Adam <adam@adambard.com> | 2016-01-08 14:35:53 +0800 |
commit | ef28fa69775ba064dfed212e034b5caae7edb7b9 (patch) | |
tree | d3a30be274822754414b438fe9b9c102edc09630 /perl6.html.markdown | |
parent | 8ad537a9ba9889234a63c5a38caeab3e225856e4 (diff) | |
parent | 04166190367a93236e7173901dff7ae9661736ba (diff) |
Merge branch 'master' of github.com:adambard/learnxinyminutes-docs
Diffstat (limited to 'perl6.html.markdown')
-rw-r--r-- | perl6.html.markdown | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/perl6.html.markdown b/perl6.html.markdown index 1829f964..5082a433 100644 --- a/perl6.html.markdown +++ b/perl6.html.markdown @@ -103,7 +103,7 @@ sub say-hello-to(Str $name) { # You can provide the type of an argument ## It can also have optional arguments: sub with-optional($arg?) { # the "?" marks the argument optional - say "I might return `(Any)` (Perl's "null"-like value) if I don't have + say "I might return `(Any)` (Perl's 'null'-like value) if I don't have an argument passed, or I'll return my argument"; $arg; } @@ -803,9 +803,8 @@ module Foo::Bar { my sub unavailable { # `my sub` is the default say "Can't access me from outside, I'm my !"; } + say ++$n; # increment the package variable and output its value } - - say ++$n; # lexically-scoped variables are still available } say $Foo::Bar::n; #=> 1 Foo::Bar::inc; #=> 2 @@ -1330,7 +1329,7 @@ so 'ayc' ~~ / a [ b | y ] c /; # `True`. Obviously enough ... -### Extra: the MAIN subroutime +### Extra: the MAIN subroutine # The `MAIN` subroutine is called when you run a Perl 6 file directly. # It's very powerful, because Perl 6 actually parses the arguments # and pass them as such to the sub. It also handles named argument (`--foo`) |