Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
30
Task/Classes/EMal/classes.emal
Normal file
30
Task/Classes/EMal/classes.emal
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
type Bear ^| the type system is informed about the new type,
|
||||
| here we are in the static context
|
||||
|^
|
||||
model # instance context
|
||||
text name # instance variable
|
||||
^|
|
||||
| in EMal the instance variables are ordered, and a default
|
||||
| variadic constructor is provided by the runtime.
|
||||
| Every value passed to the constructor sets the instance variable
|
||||
| according to the order.
|
||||
|^
|
||||
fun makeNoise = void by block # method of Bear
|
||||
writeLine("Growl!")
|
||||
end
|
||||
end
|
||||
type Cat
|
||||
model
|
||||
text noise
|
||||
new by text noise # an explicit constructor
|
||||
me.noise = noise # we must use me to access instance variables
|
||||
end
|
||||
fun makeNoise = void by block
|
||||
writeLine(me.noise)
|
||||
end
|
||||
end
|
||||
type Main
|
||||
Bear bear = Bear("Bruno") # creating a new instance
|
||||
writeLine("The bear is called " + bear.name)
|
||||
bear.makeNoise()
|
||||
Cat("Meow").makeNoise()
|
||||
Loading…
Add table
Add a link
Reference in a new issue