2025-09-08 15:30:24 +01:00
|
|
|
y = 1 + 2 * 3 / 4 * 5 - 6 + 7 multiplyBy:2.
|
|
|
|
|
z = w = 2 + 3 multiplyBy:2.
|
|
|
|
|
x = (((1 + 2 * 3) multiplyBy:3) add: 5) + 2.
|
2024-12-02 10:48:32 +00:00
|
|
|
x = ((1 + 2 * 3) multiplyBy:3).
|
2025-11-04 10:38:16 +00:00
|
|
|
p = 5 multiply(by:3, add:(2 + 1)).
|
2025-09-08 15:30:24 +01:00
|
|
|
q = 10 squared squared.
|
2024-12-02 11:00:00 +00:00
|
|
|
|
|
|
|
|
p1
|
2025-11-04 10:38:16 +00:00
|
|
|
setAge:2 squared squared + 4 squared multiply(by:2, add:4 + 1 * 3)
|
2024-12-02 11:00:00 +00:00
|
|
|
in:"mon" + "ths".
|
2024-12-03 21:58:02 +00:00
|
|
|
|
2025-09-08 15:30:24 +01:00
|
|
|
m = xz multiply(by:3 add:2) squared.
|
2024-12-03 21:58:02 +00:00
|
|
|
|
2025-04-15 11:05:52 +01:00
|
|
|
m = xz multiply(by:3 add:2); squared.
|
2024-12-03 21:58:02 +00:00
|
|
|
|
2025-09-08 15:30:24 +01:00
|
|
|
x = OrderedCollection new
|
2024-12-03 21:58:02 +00:00
|
|
|
add: 2;
|
|
|
|
|
add: 4;
|
|
|
|
|
add: 6;
|
|
|
|
|
yourself.
|
|
|
|
|
|
2025-11-04 10:38:16 +00:00
|
|
|
age = Person new(name:"John Doe", age:34)
|
2024-12-03 21:58:02 +00:00
|
|
|
setAge:144 inUnit:"months";
|
2024-12-04 16:35:54 +00:00
|
|
|
ageInMonths.
|
|
|
|
|
|
2024-12-04 22:23:33 +00:00
|
|
|
x = 5.
|
2025-09-08 15:30:24 +01:00
|
|
|
q = 10 if x > 2 else 20.
|
2024-12-04 22:23:33 +00:00
|
|
|
q = if x > 2 then 10 else 20 end.
|
|
|
|
|
|
2025-11-04 10:38:16 +00:00
|
|
|
cout put:5 multiply(by:5, add:2) if x > 2.
|
2024-12-04 22:23:33 +00:00
|
|
|
|
|
|
|
|
if x > 2 then
|
|
|
|
|
cout put:"Greater"
|
|
|
|
|
else
|
|
|
|
|
cout put:"Less"
|
|
|
|
|
end
|
|
|
|
|
|
2025-09-08 15:30:24 +01:00
|
|
|
q = match yz in
|
2024-12-04 22:23:33 +00:00
|
|
|
1 => age = age,
|
|
|
|
|
2 => age = age / 12,
|
|
|
|
|
3 => age = age / 365,
|
|
|
|
|
_ => age = 0
|
2024-12-05 19:29:36 +00:00
|
|
|
end.
|
|
|
|
|
|
|
|
|
|
while x > 2 do
|
|
|
|
|
cout put:"message"
|
|
|
|
|
end
|
|
|
|
|
|
2024-12-06 10:02:51 +00:00
|
|
|
for i in 0 to:100 step:2 do
|
2024-12-06 19:51:01 +00:00
|
|
|
cout put:'Count is {i}'
|
2024-12-06 10:02:51 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
cout put:"message" while x > 2.
|
2024-12-06 13:47:21 +00:00
|
|
|
cout put:'Count is {i}' for i in 0 to:100 step:2.
|
2024-12-06 10:02:51 +00:00
|
|
|
|
2025-09-08 15:30:24 +01:00
|
|
|
z = do
|
|
|
|
|
x = 1.
|
|
|
|
|
y = 2.
|
2024-12-06 10:02:51 +00:00
|
|
|
^x + y
|
|
|
|
|
end.
|
2024-12-06 13:47:21 +00:00
|
|
|
|
2025-09-08 15:30:24 +01:00
|
|
|
j = [ cout put:'Hello!' ].
|
|
|
|
|
k = [ :x :y | cout put:'Hello, {x}, {y}!' ].
|
2024-12-07 11:17:01 +00:00
|
|
|
|
|
|
|
|
x > 2
|
|
|
|
|
if:[ cout put:'True' ]
|
|
|
|
|
else:[ cout put: 'False' ].
|
|
|
|
|
|
|
|
|
|
0 to:100 step:2 do:[ :i | cout put:'Count: {i}' ].
|
|
|
|
|
|
|
|
|
|
p1 test(param:'Hello' :'World').
|
2024-12-07 20:57:08 +00:00
|
|
|
|
2025-09-08 15:30:24 +01:00
|
|
|
pkg = {}.
|
2024-12-07 20:57:08 +00:00
|
|
|
pkg = { 0 }.
|
|
|
|
|
pkg = { 1, 2, 3, 4, 5 }.
|
|
|
|
|
pkg = { 10, 2 => "Hello", 9, 5 => "World", 14 }.
|
|
|
|
|
pkg = { { 0 }, { 1 }, { y for y in huh } }.
|
|
|
|
|
|
2024-12-08 19:37:33 +00:00
|
|
|
pkg = { x multiplyBy:2 for x in wow if x > 2 }.
|
|
|
|
|
|
|
|
|
|
pkg->x = 32.
|
2025-03-26 22:27:06 +00:00
|
|
|
k = (1 multiplyBy:2, 4).
|
2024-12-08 19:37:33 +00:00
|
|
|
|
|
|
|
|
for (x, y) in pkg do
|
|
|
|
|
cout put:'{x}: {y}'
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
pkg[0] = 16.
|
|
|
|
|
|
|
|
|
|
/* All of these accesses are equivalent */
|
|
|
|
|
pkg['x'] = 32.
|
|
|
|
|
pkg->x = 32.
|
2025-03-26 22:27:06 +00:00
|
|
|
pkg at:'x' put:32.
|
|
|
|
|
|
2025-09-08 15:30:24 +01:00
|
|
|
v = pkg['x'].
|
2025-03-26 22:27:06 +00:00
|
|
|
v = pkg->x.
|
|
|
|
|
v = pkg at:'x'.
|
|
|
|
|
|
2025-09-08 15:30:24 +01:00
|
|
|
pkg2 = {
|
2025-03-26 22:27:06 +00:00
|
|
|
onEnter => [
|
|
|
|
|
cout put:'start!'
|
|
|
|
|
],
|
|
|
|
|
|
|
|
|
|
onExit => [
|
|
|
|
|
cout put:'end!'
|
|
|
|
|
]
|
|
|
|
|
}.
|
2024-12-08 19:37:33 +00:00
|
|
|
|
2025-09-08 15:30:24 +01:00
|
|
|
index = 'x'.
|
2024-12-08 19:37:33 +00:00
|
|
|
pkg[index] = 32.
|
2025-09-08 15:30:24 +01:00
|
|
|
pkg at:index put:32
|