doc: update complex-msg syntax examples
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
2 + 3 * 4.
|
||||
var y = 32.
|
||||
var f = [ :x | x * 2 + y ].
|
||||
var result = f(4).
|
||||
|
||||
Reference in New Issue
Block a user