Anonymous user
Compound data type: Difference between revisions
→{{header|Tcl}}: Alternative techniques
(→{{header|Tcl}}: Alternative techniques) |
|||
Line 902:
=={{header|Tcl}}==
This
<lang tcl>array set point {x 4 y 5}
set point(y) 7
puts "Point is {$point(x),$point(y)}"
# => Point is {4,7}</lang>
Or a dictionary:
{{works with|Tcl|8.5}}
<lang tcl>set point [dict create x 4 y 5]
dict set point y 7
puts "Point is {[dict get $point x],[dict get $point y]}"</lang>
Or an object:
{{works with|Tcl|8.6}}
<lang tcl>oo::class create Point {
variable x y
constructor {X Y} {set x $X;set y $Y}
method x {args} {set x {*}$args}
method y {args} {set y {*}$args}
method show {} {return "{$x,$y}"}
}
Point create point 4 5
point y 7
puts "Point is [point show]"</lang>
=={{header|TI-89 BASIC}}==
|