doc: update complex-msg syntax examples

This commit is contained in:
2025-04-23 10:55:54 +01:00
parent 279b387b69
commit 0cdefbeec3
2 changed files with 11 additions and 15 deletions

View File

@@ -138,16 +138,10 @@ class Person
-> exampleProperty4 (get)
end
p1 = Person new(name:'John Doe' age:34).
p1 = Person new(name:'John Doe', age:34).
p1 setAge:100 inUnit:$months.
/**
when sending a message with unlabeled parameters, the preceding colon (:) is
still required. this is part of the reason why unlabeled parameters are
weird and not recommended.
**/
p1 test(param:'Hello' :'World').
p1 test(param:'Hello', 'World').
/******************************************************************************/
@@ -388,10 +382,10 @@ cout put:'Hello, world!' if x > 10.
**/
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'.
(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')).
/******************************************************************************/
@@ -445,7 +439,7 @@ pkg2 = pkg1 map:[ :x | ^x * 2 ].
single recipient.
**/
age = Person new(name:'John Doe' age:34);
age = Person new(name:'John Doe', age:34);
setAge:144 inUnit:$months;
ageInMonths.
@@ -453,7 +447,7 @@ age = Person new(name:'John Doe' age:34);
-- the same behaviour can be achieved by using do..end
age = do
x = Person new(name:'John Doe' age:34).
x = Person new(name:'John Doe', age:34).
x setAge:144 inUnit:$months.
x ageInMonths
end
@@ -476,7 +470,7 @@ end
all objects by default and always returns the object itself::
**/
p1 = Person new(name:'John Doe' age:34);
p1 = Person new(name:'John Doe', age:34);
setAge:100 inUnit:$months;
yourself::
@@ -484,7 +478,7 @@ p1 = Person new(name:'John Doe' age:34);
/* again, with do..end */
p1 = do
x = Person new(name:'John Doe' age:34).
x = Person new(name:'John Doe', age:34).
x setAge:100 inUnit:$months.
x
end.