Polymorphism: Difference between revisions
→{{header|jq}}: def set(keyname;value)
(→{{header|jq}}: tweaks) |
(→{{header|jq}}: def set(keyname;value)) |
||
Line 2,047:
In practice, it's unlikely one would want to write accessors, as .x will retrieve "x", etc; similar remarks apply to setters (.x = VALUE). `.` will copy, and `empty` could serve as a kind of destructor, in that `Point(0;0) | empty` produces the empty stream.
For the sake of illustration, one could define a
<lang jq>
# keyname should be (or evaluate to) a string
def set(keyname; value):
</lang>
Example:
|