Classes: Difference between revisions

606 bytes added ,  2 years ago
Line 4,085:
#1 Mazda 1000 $0 undefined, true false
#2 Volvo 2000 $30000 2, true true
</pre>
 
=={{header|Transd}}==
<lang Scheme>#lang transd
 
class Point : {
x: Double(),
y: Double(),
@init: (λ v Vector<Double>() (= x (get v 0)) (= y (get v 1))),
print: (λ (textout "Point(" x "; " y ")\n" ))
}
 
MainModule: {
v_: [[1.0, 2.0], [3.0, 4.0]],
 
_start: (λ
// creating an instance of class
(with pt Point([5.0, 6.0])
// calling a class' method
(print pt)
)
 
// creating several instances using data deserialization
(with v Vector<Point>(v_)
(for p in v do (print p))
) )
}</lang>
{{out}}
<pre>
Point(5; 6)
Point(1; 2)
Point(3; 4)
</pre>
 
111

edits