Skip to content

Idea: @noGetters @noConstructor #390

@gavr123456789

Description

@gavr123456789
@{noGetters noConstructor}
type Point
  x: Int
  y: Int

p = Point x: 1 y: 2 // ERROR

p x // ERROR

// need to define custom constructor with our rules
constructor Point atStart = Point x: 0 y: 0

constructor Point x::Int y::Int -> Point! = [
  x < 0 || y < 0, ifTrue: [Error throw: "wrong!!"]
  ^ Point x: x y: y
]

p = Point atStart
p = Point x: -1 y: -2 // throws

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions