Home /Examples/lib/examples/sleela/NEW-struct-record.sleela

NEW-struct-record.sleela

lib/examples/sleela/NEW-struct-record.sleela · 12 line(s) · sleela

#sleela 1.7
// NEW: a struct models data separately from the class that operates on it.
struct Point { int x; int y; }
class NewStructRecord {
    void main() {
        Point point = new Point();
        point.x = 3; point.y = 4;
        print("point = (" + point.x + ", " + point.y + ")");
        print("manhattan distance = " + (point.x + point.y));
    }
}