Bladeren bron

use `--` for comments

tcheukueppo 2 jaren geleden
bovenliggende
commit
72313b4e95
1 gewijzigde bestanden met toevoegingen van 28 en 28 verwijderingen
  1. 28 28
      docs/pity_dev_ref/pity.md

+ 28 - 28
docs/pity_dev_ref/pity.md

@@ -149,7 +149,7 @@ a = |one two three|
 # [ "Three", "TWo", "One" ], Lennon Stella :-)
 # [ "Three", "TWo", "One" ], Lennon Stella :-)
 b = a.map{.capitalize}.reverse
 b = a.map{.capitalize}.reverse
 
 
-# [ "0ne", "tw0", "three" ]
+-- [ "0ne", "tw0", "three" ]
 a =~ s<o>«0»
 a =~ s<o>«0»
 ```
 ```
 
 
@@ -170,7 +170,7 @@ say q%interpolation won't work%
 
 
 say qq/interpolation works, array: #a/
 say qq/interpolation works, array: #a/
 
 
-# [ "0ne", "Tw0" ]
+-- [ "0ne", "Tw0" ]
 b = a.grep({(x) x =~ m|o| }).map({ s|o|0|r }).map(.ucfirst)
 b = a.grep({(x) x =~ m|o| }).map({ s|o|0|r }).map(.ucfirst)
 b.say
 b.say
 ```
 ```
@@ -230,17 +230,17 @@ fn increment(n) {
     __FUNC__(nil), return k if ++k != 9
     __FUNC__(nil), return k if ++k != 9
 }
 }
 
 
-# 9
+-- 9
 increment(0, 9).say
 increment(0, 9).say
 ```
 ```
 constant variables are lexically scoped by default unless you precise they're global with the global
 constant variables are lexically scoped by default unless you precise they're global with the global
 keyword.
 keyword.
 
 
 ```raku
 ```raku
-# lexically scoped constant
+-- lexically scoped constant
 const z = 4
 const z = 4
 
 
-# a constant global
+-- a constant global
 const global (x, y) = (2, 10)
 const global (x, y) = (2, 10)
 ```
 ```
 
 
@@ -345,10 +345,10 @@ say 2; say 3
 
 
 ```raku
 ```raku
 var v = do { 2 }
 var v = do { 2 }
-# "2"
+-- "2"
 say v
 say v
 
 
-# "3"
+-- "3"
 (do { 3 }).say
 (do { 3 }).say
 
 
 do { false } or die "failed"
 do { false } or die "failed"
@@ -364,15 +364,15 @@ bg {
     say "done"
     say "done"
 }
 }
 
 
-# declare a function and assign it to "a"
+-- declare a function and assign it to "a"
 var a = fn { sleep 4; say "done" }
 var a = fn { sleep 4; say "done" }
 
 
-# run function in "a" asyncronously and return a promise
+-- run function in "a" asyncronously and return a promise
 var p = bg a.call
 var p = bg a.call
 
 
 say "do stuffs"
 say "do stuffs"
 
 
-# await promise p
+-- await promise p
 fg p
 fg p
 ```
 ```
 
 
@@ -408,10 +408,10 @@ the returned value of the expression.
 ```raku
 ```raku
 var (u, y) = (5, nil)
 var (u, y) = (5, nil)
 
 
-# 5, 5
+-- 5, 5
 with u { say _, u }
 with u { say _, u }
 
 
-# 5
+-- 5
 with   y      { say "never here" }
 with   y      { say "never here" }
 orwith u -> m { say m }
 orwith u -> m { say m }
 else          { say "never here" }
 else          { say "never here" }
@@ -422,22 +422,22 @@ else          { say "never here" }
 ```ruby
 ```ruby
 for "a", qr/regex/, [2, 4] { .say }
 for "a", qr/regex/, [2, 4] { .say }
 
 
-# output: 3 3 5 4 4
+-- output: 3 3 5 4 4
 for ar -> i { i.len.say }
 for ar -> i { i.len.say }
 
 
 ar = <one two three four five>
 ar = <one two three four five>
-# "ar" is now [3, 3, 5, 4, 4]
+-- "ar" is now [3, 3, 5, 4, 4]
 for ar -> j {
 for ar -> j {
     j = j.len
     j = j.len
 }
 }
 
 
-# (3, 3) (5, 4) (4, nil)
+-- (3, 3) (5, 4) (4, nil)
 for ar {(i,j)
 for ar {(i,j)
     say "(#i, #j)"
     say "(#i, #j)"
 }
 }
 
 
-# set a custom value when we are running out of elements
-# (3, 3) (5, 4) (4, none)
+-- set a custom value when we are running out of elements
+-- (3, 3) (5, 4) (4, none)
 for ar -> i, j = "none" {
 for ar -> i, j = "none" {
     say "(#i, #j)"
     say "(#i, #j)"
 }
 }
@@ -477,14 +477,14 @@ operator(`~~`). We execute the block of the first matching case and instantly ex
 We can continue on to the next case by using the `proceed` instruction within the block of a case.
 We can continue on to the next case by using the `proceed` instruction within the block of a case.
 
 
 ```raku
 ```raku
-# output: Num, 42
+-- output: Num, 42
 given 34 {
 given 34 {
   when Num { say "Num"; proceed }
   when Num { say "Num"; proceed }
   when 42  { say "42" }
   when 42  { say "42" }
   default  { say "Default" }
   default  { say "Default" }
 }
 }
 
 
-# use '|' for alternation
+-- use '|' for alternation
 var name = kueppo
 var name = kueppo
 given name {
 given name {
     /^k/ | /o$/ { say "matches" }
     /^k/ | /o$/ { say "matches" }
@@ -514,7 +514,7 @@ general form: `loop initializer; condition; step { ... }`
 ```raku
 ```raku
 loop var k = 0; k ≤ 20; k² { k.say }
 loop var k = 0; k ≤ 20; k² { k.say }
 
 
-# you can skip some parts
+-- you can skip some parts
 loop var k = 0;;k++ {
 loop var k = 0;;k++ {
     k.say
     k.say
     break if k == 10
     break if k == 10
@@ -568,13 +568,13 @@ performs the action for the current block.
 labels permits you to jump between labeled blocks using a loop control statement
 labels permits you to jump between labeled blocks using a loop control statement
 
 
 ```raku
 ```raku
-# an infinite loop with prints "one"
+-- an infinite loop with prints "one"
 ONE: {
 ONE: {
     say "one"
     say "one"
     redo ONE
     redo ONE
 }
 }
 
 
-# print "two" to the stdout and repeatly print "three"
+-- print "two" to the stdout and repeatly print "three"
 TWO: {
 TWO: {
     say "two"
     say "two"
     THREE: {
     THREE: {
@@ -600,7 +600,7 @@ for h.each_kv {
     printfln "%s => %d", k, v
     printfln "%s => %d", k, v
 }
 }
 
 
-# for syntatic suger
+-- for syntatic suger
 for h.each_kv -> k, v {
 for h.each_kv -> k, v {
     once say 'only once!' if v == 1
     once say 'only once!' if v == 1
     printfln "%s => %d", k, v
     printfln "%s => %d", k, v
@@ -623,14 +623,14 @@ NOTE: topic variables should only be named at the begining of the block of conce
 ```raku
 ```raku
 var a = [2, 5, 34]
 var a = [2, 5, 34]
 
 
-# declaring a topic variable x
+-- declaring a topic variable x
 print a.map {(x)
 print a.map {(x)
     once x++
     once x++
     next if x == 3
     next if x == 3
     √x
     √x
 }
 }
 
 
-# 2,2 4,none
+-- 2,2 4,none
 [2, 2, 4].each {
 [2, 2, 4].each {
     (x, y = "none")
     (x, y = "none")
     say "#x,#y"
     say "#x,#y"
@@ -659,7 +659,7 @@ intro("kueppo", "20")
 intro("sarah")
 intro("sarah")
 intro(age => 5, name => liza)
 intro(age => 5, name => liza)
 
 
-# no candidates for this and thus fails at compile time
+-- no candidates for this and thus fails at compile time
 intro(age)
 intro(age)
 
 
 fn mul(Str str, Int k) { say str * k }
 fn mul(Str str, Int k) { say str * k }
@@ -671,7 +671,7 @@ mul("two")
 
 
 # Classes & Roles
 # Classes & Roles
 
 
-```raku
+```lua
 role D { ... }
 role D { ... }
 role E { ... }
 role E { ... }
 
 
@@ -682,7 +682,7 @@ class C { ... }
 class A isa B, C does D, E {
 class A isa B, C does D, E {
     has x is ro -- readonly attribute, say A.x
     has x is ro -- readonly attribute, say A.x
     has y is rw -- read-write attribute, A.y = 2; say A.y
     has y is rw -- read-write attribute, A.y = 2; say A.y
-    has z -- simple attribute with no generated accessors
+    has z       -- simple attribute with no generated accessors
 
 
     method xyz() {
     method xyz() {
         -- self.x, self.y, etc.
         -- self.x, self.y, etc.