Accumulator factory: Difference between revisions
→{{header|EMal}}
No edit summary |
|||
Line 1,043:
|that are usually not nullable, such as int or real.
|In the following code we are telling EMal that int and real implement
|the Number virtual interface, so that it can only
|accept null (because it's an interface), int, and real values.
|^
type Number
type AccumulatorUsingNumber
fun foo = fun by Number n
Line 1,078 ⟶ 1,079:
for int i = 0; i < 2; ++i
generic solution = solutions[i]
writeLine("=== solution
fun x = :solution.foo(1)
x(5)
Line 1,091 ⟶ 1,092:
{{out}}
<pre>
=== solution
Org:RosettaCode:Number, Real: <8.3>
Org:RosettaCode:Number, Integer: <8>
=== solution
Variable, Real: <8.3>
Variable, Integer: <8>
|