Compound data type: Difference between revisions
Content added Content deleted
(added Clojure version) |
No edit summary |
||
Line 431: | Line 431: | ||
point := Point{x := 3, y := 4}; |
point := Point{x := 3, y := 4}; |
||
</pre> |
</pre> |
||
=={{header|Objeck}}== |
|||
Classes are used for compound data types. |
|||
<lang objeck> |
|||
class Point { |
|||
@x : Int; |
|||
@y : Int; |
|||
New() { |
|||
@x := 0; |
|||
@y := 0; |
|||
} |
|||
New(x : Int, y : Int) { |
|||
@x := x; |
|||
@y := y; |
|||
} |
|||
New(p : Point) { |
|||
@x := p->GetX(); |
|||
@y := p->GetY(); |
|||
} |
|||
method : public : GetX() ~ Int { |
|||
return @x; |
|||
} |
|||
method : public : GetY() ~ Int { |
|||
return @y; |
|||
} |
|||
method : public : SetX(x : Int) ~ Nil { |
|||
@x := x; |
|||
} |
|||
method : public : SetY(y : Int) ~ Nil { |
|||
@y := y; |
|||
} |
|||
} |
|||
</lang> |
|||
=={{header|OCaml}}== |
=={{header|OCaml}}== |