doc: sample: remove var keyword

This commit is contained in:
2025-09-08 15:30:24 +01:00
parent ebfbbd0a1a
commit cb63e8d016
2 changed files with 22 additions and 23 deletions

View File

@@ -1,30 +1,30 @@
var y = 1 + 2 * 3 / 4 * 5 - 6 + 7 multiplyBy:2. y = 1 + 2 * 3 / 4 * 5 - 6 + 7 multiplyBy:2.
var z = w = 2 + 3 multiplyBy:2. z = w = 2 + 3 multiplyBy:2.
var x = (((1 + 2 * 3) multiplyBy:3) add: 5) + 2. x = (((1 + 2 * 3) multiplyBy:3) add: 5) + 2.
x = ((1 + 2 * 3) multiplyBy:3). x = ((1 + 2 * 3) multiplyBy:3).
var p = 5 multiply(by:3 add:(2 + 1)). p = 5 multiply(by:3 add:(2 + 1)).
var q = 10 squared squared. q = 10 squared squared.
p1 p1
setAge:2 squared squared + 4 squared multiply(by:2 add:4 + 1 * 3) setAge:2 squared squared + 4 squared multiply(by:2 add:4 + 1 * 3)
in:"mon" + "ths". in:"mon" + "ths".
var m = xz multiply(by:3 add:2) squared. m = xz multiply(by:3 add:2) squared.
m = xz multiply(by:3 add:2); squared. m = xz multiply(by:3 add:2); squared.
var x = OrderedCollection new x = OrderedCollection new
add: 2; add: 2;
add: 4; add: 4;
add: 6; add: 6;
yourself. yourself.
var age = Person new(name:"John Doe" age:34) age = Person new(name:"John Doe" age:34)
setAge:144 inUnit:"months"; setAge:144 inUnit:"months";
ageInMonths. ageInMonths.
x = 5. x = 5.
var q = 10 if x > 2 else 20. q = 10 if x > 2 else 20.
q = if x > 2 then 10 else 20 end. q = if x > 2 then 10 else 20 end.
cout put:5 multiply(by:5 add:2) if x > 2. cout put:5 multiply(by:5 add:2) if x > 2.
@@ -35,7 +35,7 @@ else
cout put:"Less" cout put:"Less"
end end
var q = match yz in q = match yz in
1 => age = age, 1 => age = age,
2 => age = age / 12, 2 => age = age / 12,
3 => age = age / 365, 3 => age = age / 365,
@@ -53,14 +53,14 @@ end
cout put:"message" while x > 2. cout put:"message" while x > 2.
cout put:'Count is {i}' for i in 0 to:100 step:2. cout put:'Count is {i}' for i in 0 to:100 step:2.
var z = do z = do
var x = 1. x = 1.
var y = 2. y = 2.
^x + y ^x + y
end. end.
var j = [ cout put:'Hello!' ]. j = [ cout put:'Hello!' ].
var k = [ :x :y | cout put:'Hello, {x}, {y}!' ]. k = [ :x :y | cout put:'Hello, {x}, {y}!' ].
x > 2 x > 2
if:[ cout put:'True' ] if:[ cout put:'True' ]
@@ -70,7 +70,7 @@ x > 2
p1 test(param:'Hello' :'World'). p1 test(param:'Hello' :'World').
var pkg = {}. pkg = {}.
pkg = { 0 }. pkg = { 0 }.
pkg = { 1, 2, 3, 4, 5 }. pkg = { 1, 2, 3, 4, 5 }.
pkg = { 10, 2 => "Hello", 9, 5 => "World", 14 }. pkg = { 10, 2 => "Hello", 9, 5 => "World", 14 }.
@@ -92,11 +92,11 @@ pkg['x'] = 32.
pkg->x = 32. pkg->x = 32.
pkg at:'x' put:32. pkg at:'x' put:32.
var v = pkg['x']. v = pkg['x'].
v = pkg->x. v = pkg->x.
v = pkg at:'x'. v = pkg at:'x'.
var pkg2 = { pkg2 = {
onEnter => [ onEnter => [
cout put:'start!' cout put:'start!'
], ],
@@ -106,6 +106,6 @@ var pkg2 = {
] ]
}. }.
var index = 'x'. index = 'x'.
pkg[index] = 32. pkg[index] = 32.
pkg at:index put:32. pkg at:index put:32

View File

@@ -1,3 +1,2 @@
var x = 2 + 255 * 3 / 63. z = 32.
cout put:"iteration" while z > 0
cout put:x.