Is it possible to create a class with an immutable reference to a partner object, or does it have to be a var
that I assign after creation?
e.g.
class PairedObject (p: PairedObject, id: String) {
val partner: PairedObject = p // but I need ref to this object to create p!
}
or similarly how could I instantiate the following pair?
class Chicken (e: Egg) {
val offspring = e
}
class Egg (c: Chicken) {
val mother = c
}
chicken
andegg
don't need to be lazy. Strictly you don't need to include types for both, as one can be inferred. – Potherb