Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Tidied up some code examples a bit
  • Loading branch information
Jan-Olof Hendig committed Jun 3, 2016
1 parent 187aef3 commit 91eaf67
Showing 1 changed file with 31 additions and 31 deletions.
62 changes: 31 additions & 31 deletions doc/Type/Str.pod
Expand Up @@ -55,7 +55,7 @@ Returns a lower-case version of the string.
Examples:
lc("A"); # returns "a"
"A".lc # returns "a"
"A".lc; # returns "a"
=head2 routine uc
Expand Down Expand Up @@ -168,7 +168,7 @@ Examples:
say index "Camelia is a butterfly", "a", 2; # 6
say index "Camelia is a butterfly", "er"; # 17
say index "Camelia is a butterfly", "Camel"; # 0
say index "Camelia is a butterfly", "Onion"; # Int()
say index "Camelia is a butterfly", "Onion"; # Nil
say index("Camelia is a butterfly", "Onion").defined ?? 'OK' !! 'NOT'; # NOT
Expand Down Expand Up @@ -255,22 +255,22 @@ Examples:
=begin code
say split(";", "a;b;c").perl # ("a", "b", "c")
say split(";", "a;b;c", :v).perl # ("a", ";", "b", ";", "c")
say split(";", "a;b;c", 2).perl # ("a", "b;c").Seq
say split(";", "a;b;c", 2, :v).perl # ("a", ";", "b;c")
say split(";", "a;b;c,d").perl # ("a", "b", "c,d")
say split(/\;/, "a;b;c,d").perl # ("a", "b", "c,d")
say split(<; ,>, "a;b;c,d").perl # ("a", "b", "c", "d")
say split(/<[;,]>/, "a;b;c,d").perl # ("a", "b", "c", "d")
say split(<; ,>, "a;b;c,d", :k).perl # ("a", 0, "b", 0, "c", 1, "d")
say split(<; ,>, "a;b;c,d", :kv).perl # ("a", 0, ";", "b", 0, ";", "c", 1, ",", "d")
say split(";", "a;b;c").perl; # ("a", "b", "c")
say split(";", "a;b;c", :v).perl; # ("a", ";", "b", ";", "c")
say split(";", "a;b;c", 2).perl; # ("a", "b;c").Seq
say split(";", "a;b;c", 2, :v).perl; # ("a", ";", "b;c")
say split(";", "a;b;c,d").perl; # ("a", "b", "c,d")
say split(/\;/, "a;b;c,d").perl; # ("a", "b", "c,d")
say split(<; ,>, "a;b;c,d").perl; # ("a", "b", "c", "d")
say split(/<[;,]>/, "a;b;c,d").perl; # ("a", "b", "c", "d")
say split(<; ,>, "a;b;c,d", :k).perl; # ("a", 0, "b", 0, "c", 1, "d")
say split(<; ,>, "a;b;c,d", :kv).perl; # ("a", 0, ";", "b", 0, ";", "c", 1, ",", "d")
say "".split("x").perl # ("",)
say "".split("x", :skip-empty).perl # ("",)
say "".split("x").perl; # ("",)
say "".split("x", :skip-empty).perl; # ("",)
say "abcde".split("").perl # ("", "a", "b", "c", "d", "e", "")
say "abcde".split("",:skip-empty).perl # ("a", "b", "c", "d", "e")
say "abcde".split("").perl; # ("", "a", "b", "c", "d", "e", "")
say "abcde".split("",:skip-empty).perl; # ("a", "b", "c", "d", "e")
=end code
Expand All @@ -294,10 +294,10 @@ If no matcher is supplied, a list of characters in the string
Examples:
comb(/\w/, "a;b;c").perl; # ("a", "b", "c").list
comb(/\N/, "a;b;c").perl; # ("a", ";", "b", ";", "c").list
comb(/\w/, "a;b;c", 2).perl; # ("a", "b").list
comb(/\w\;\w/, "a;b;c", 2).perl; # ("a;b",).list
say comb(/\w/, "a;b;c").perl; # ("a", "b", "c").Seq
say comb(/\N/, "a;b;c").perl; # ("a", ";", "b", ";", "c").Seq
say comb(/\w/, "a;b;c", 2).perl; # ("a", "b").Seq
say comb(/\w\;\w/, "a;b;c", 2).perl; # ("a;b",).Seq
If the matcher is an integer value, it is considered to be a matcher that
is similar to / . ** matcher /, but which is about 30x faster.
Expand All @@ -312,10 +312,10 @@ same as a call to C<$input.comb( / ^^ \N* /, $limit )> would.
Examples:
lines("a\nb").perl; # ("a", "b").list
lines("a\nb").elems; # 2
"a\nb".lines.elems; # 2
"a\n".lines.elems; # 1
say lines("a\nb").perl; # ("a", "b").Seq
say lines("a\nb").elems; # 2
say "a\nb".lines.elems; # 2
say "a\n".lines.elems; # 1
=head2 routine words
Expand All @@ -327,10 +327,10 @@ C<$input.comb( / \S+ /, $limit )> would.
Examples:
"a\nb\n".words.perl; # ("a", "b").list
"hello world".words.perl; # ("hello", "world").list
"foo:bar".words.perl; # ("foo:bar",).list
"foo:bar\tbaz".words.perl; # ("foo:bar", "baz").list
say "a\nb\n".words.perl; # ("a", "b").Seq
say "hello world".words.perl; # ("hello", "world").Seq
say "foo:bar".words.perl; # ("foo:bar",).Seq
say "foo:bar\tbaz".words.perl; # ("foo:bar", "baz").Seq
=head2 routine flip
Expand Down Expand Up @@ -530,7 +530,7 @@ Special case: sprintf("<b>%s</b>\n", "Perl 6") will not work use either of the
multi method starts-with(Str:D: Str(Cool) $needle) returns True:D
Returns True if the invocant is identical to or starts with C<$needle>.
Returns C<True> if the invocant is identical to or starts with C<$needle>.
say "Hello, World".starts-with("Hello"); # True
say "http://perl6.org/".starts-with('ftp'); # False
Expand All @@ -539,7 +539,7 @@ Returns True if the invocant is identical to or starts with C<$needle>.
multi method ends-with(Str:D: Str(Cool) $needle) returns True:D
Returns True if the invocant is identical to or ends with C<$needle>.
Returns C<True> if the invocant is identical to or ends with C<$needle>.
say "Hello, World".ends-with('Hello'); # False
say "Hello, World".ends-with('ld'); # True
Expand All @@ -548,7 +548,7 @@ Returns True if the invocant is identical to or ends with C<$needle>.
multi method contains(Str:D: Str(Cool) $needle) returns True:D
Returns True if the invocant contains the C<$needle> at any position within
Returns C<True> if the invocant contains the C<$needle> at any position within
the string.
say "Hello, World".contains('hello'); # False
Expand Down

0 comments on commit 91eaf67

Please sign in to comment.