Accumulator factory: Difference between revisions
m
Added Sidef
(→{{header|D}}: Add Déjà Vu example) |
m (Added Sidef) |
||
Line 1,736:
factory value:3.
(a value:2.3) printCR "-> 8.3 "</lang>
=={{header|Sidef}}==
<lang ruby>class Accumulator (sum) {
func acc (self, num) {
self.sum(self.sum + num);
}
}
var x = Accumulator(1);
x.acc(5);
say Accumulator(3); # prints: Sidef::Variable::Class=HASH(0xa1799f8)
say x.acc(2.3); # prints: 8.3</lang>
=={{header|Standard ML}}==
|