Inheritance/Multiple: Difference between revisions

Content deleted Content added
Kotlin version enhanced
Line 237: Line 237:
MOBILE_PHONE
MOBILE_PHONE
end</lang>
end</lang>

ELENA only permits inheritance from one parent class. However, mixins are supported
<lang elena>#import system.

#symbol CameraFeature =
{
#method cameraMsg
= "camera".
}.

#class MobilePhone
{
#method mobileMsg
= "phone".
}

#class CameraPhone :: MobilePhone
{
#method => CameraFeature.
}

#symbol program =
[
#var cp := CameraPhone new.

console writeLine:(cp cameraMsg).
console writeLine:(cp mobileMsg).
].</lang>
Alternatively a group object may be created
<lang elena>#import system.
#import system'dynamic.

#class CameraFeature
{
#method cameraMsg
= "camera".
}

#class MobilePhone
{
#method mobileMsg
= "phone".
}

#symbol CameraPhone =
{
new = MobilePhone new mix &into:(CameraFeature new).
}.

#symbol program =
[
#var cp := CameraPhone new.

console writeLine:(cp cameraMsg).
console writeLine:(cp mobileMsg).
].</lang>


=={{header|Fantom}}==
=={{header|Fantom}}==