J
John-Mason P. Shackelford
Am I missing a part of the standard library that already does something
like the following?
class Counter < DelegateClass(Fixnum)
def initialize
__setobj__(0)
end
def inc
__setobj__(__getobj__.next)
self
end
end
x = Counter.new # x == 0
x.inc # x == 1
x.inc.inc.inc # x == 4
Thanks,
John-Mason Shackelford
Software Developer
Pearson Educational Measurement
2510 North Dodge St.
Iowa City, IA 52245
ph. 319-354-9200x6214
(e-mail address removed)
http://pearsonedmeasurement.com
like the following?
class Counter < DelegateClass(Fixnum)
def initialize
__setobj__(0)
end
def inc
__setobj__(__getobj__.next)
self
end
end
x = Counter.new # x == 0
x.inc # x == 1
x.inc.inc.inc # x == 4
Thanks,
John-Mason Shackelford
Software Developer
Pearson Educational Measurement
2510 North Dodge St.
Iowa City, IA 52245
ph. 319-354-9200x6214
(e-mail address removed)
http://pearsonedmeasurement.com