#DOCUMENTATION by exept
class: InlineObject class
comment/format in: #documentation
--- a/InlineObject.st Wed Feb 19 20:55:47 2020 +0100
+++ b/InlineObject.st Thu Feb 20 08:58:29 2020 +0100
@@ -64,29 +64,37 @@
InlineObjects are written as literals of the form:
- #{
- fieldName1: value1.
- fieldName2: value2.
- ...
- fieldNameN: valueN.
- }
+ #{
+ fieldName1: value1.
+ fieldName2: value2.
+ ...
+ fieldNameN: valueN.
+ }
For example:
- #{
- firstName: 'Peter'.
- lastName: 'Miller'.
- age: 25.
- }
+ #{
+ firstName: 'Peter'.
+ lastName: 'Miller'.
+ age: 25.
+ }
- #{
- date: Date today.
- time: Time now.
- }
+ The above was an inline literal: all field values must be again literals.
+
+ However, similar to brace-Arrays, inline objects can also be dynamically created (constructed):
+ {
+ date: Date today.
+ time: Time now.
+ }
All inlineObjects will be instances of an anonymous subclass of me,
and provide getter protocol for their fields (e.g. firstName, lastName and age in the above example.
- InlineObjects are immutable (no setters).
+ Literal InlineObjects are immutable (no setters), whereas constructed are not.
+
+ |foo|
+ foo := { date: Date today. time: Time now }.
+ foo date:(Date yesterday).
+ foo
"
! !