Anonymous user
Inheritance/Multiple: Difference between revisions
→{{header|Lasso}}
(Added COBOL example.) |
|||
Line 461:
//functions here...
}</lang>
=={{header|Lasso}}==
Lasso only allow single inheritance. But it supports the use of multiple traits and trays hand down the methods it has implemented provided that the type fulfills the requirements for the trait. [http://lassoguide.com/language/traits.html http://lassoguide.com/language/traits.html]
<lang Lasso>
define trait_camera => trait {
require zoomfactor
provide has_zoom() => {
return .zoomfactor > 0
}
}
define trait_mobilephone => trait {
require brand
provide is_smart() => {
return .brand == 'Apple'
}
}
define cameraphone => type {
trait {
import trait_camera, trait_mobilephone
}
data public zoomfactor::integer = 0,
public brand::string
}
local(mydevice = cameraphone)
#mydevice -> brand = 'Apple'
#mydevice -> zoomfactor = 0
#mydevice -> has_zoom
'<br />'
#mydevice -> is_smart</lang>
-> false
true
=={{header|Logtalk}}==
|