Immutable class in Eiffel
问题 I'm trying to make an immutable POINT class in Eiffel. Is the code below defines one? The {NONE} accessibility for the x and y fields is enough for it? Can I write something to the class invariant like x = x' , or how else can I achieve immutability? class POINT create make feature {NONE} x: DOUBLE y: DOUBLE feature make (x_: DOUBLE; y_: DOUBLE) do x := x_ y := y_ ensure set: x = x_ and y = y_ end feature --accessors get_x: DOUBLE do Result := x ensure Result = x end end 回答1: Eiffel does not