Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
14
Task/Constrained-genericity/E/constrained-genericity.e
Normal file
14
Task/Constrained-genericity/E/constrained-genericity.e
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
/** Guard accepting only objects with an 'eat' method */
|
||||
def Eatable {
|
||||
to coerce(specimen, ejector) {
|
||||
if (Ref.isNear(specimen) && specimen.__respondsTo("eat", 0)) {
|
||||
return specimen
|
||||
} else {
|
||||
throw.eject(ejector, `inedible: $specimen`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def makeFoodBox() {
|
||||
return [].diverge(Eatable) # A guard-constrained list
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue