RosettaCodeData/Task/Classes/Transd/classes.transd

25 lines
505 B
Plaintext

#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))
) )
}