From: aito@...5sun.yz.yamagata-u.ac.jp Date: 1998-02-05T17:20:07+09:00 Subject: [ruby-list:6289] Re: i++ あ伊藤です.またまた本質に関係ないチャチャですが In article <0520D437E251D1118E150000F68A21150154AC@WAKGW03>, 助田 雅紀 writes: > >原です。 > > > c = 0 > > array.each { |x| > > ... > > print "hello" if c % 10 == 0 > > c += 1 > > } > > >など書かなければいけない局面はかなり多いです。というか ++ が欲しい > >と思うのはこの時しかないかも。 > そうそう。私もほとんどがこういうケースです。 ということは,こんなのがあればいいんだったりして? class Counter def initialize(i = 0) @i = i end def incr; @i += 1 end def decr; @i -= 1 end def to_s; @i.to_s end def to_i; @i end end --_ ITO Akinori at YAMAGATA UNIVERSITY 伊藤 彰則 山形 大学