[squeak-dev] DynamicObjects
Thiede, Christoph
Christoph.Thiede at student.hpi.uni-potsdam.de
Sat Apr 18 17:54:56 UTC 2020
d := DynamicObject withMethods: {
#origin -> [2 @ 3].
#corner -> [3 @ 7] } asDictionary.
d origin "2 at 3"
Did we already have something like this for Squeak? May this become a pattern for situations where you actually don't need a class (e. g., when writing very small mock objects for tests)?
d := DynamicObject new.
d xxxMethodAt: #foo put: [self inform: 'Hi!'].
d xxxMethodAt: #foo: put: [:x | x halt].
d foo: 3.
Best,
Christoph
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20200418/a52e4b56/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DynamicObject.st
Type: application/octet-stream
Size: 1818 bytes
Desc: DynamicObject.st
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20200418/a52e4b56/attachment.obj>
More information about the Squeak-dev
mailing list
|