From: toyofuku@... Date: 1999-10-26T02:01:07+09:00 Subject: [ruby-list:17992] Re: <=> 豊福です。ひとり遊び状態です。 私 > class String > alias cmp <=> > def <=>(other); self.cmp((Proc === other) ? other.call: other); end > end > > class Proc > def <=>(other); self.call <=> ((Proc === other) ? other.call: other); end > end > > bar.filter{|i| a = [i.to_i, nil, i]; a[1] = proc{a[1] = a[2].to_s}; a }.sort!.filter{|i| i.pop } 本質的には何も変っていませんがあまりにもダサダサなコード だったので直しました。 class Foo def initialize(&blk) @blk = blk end def method_missing(*args) @blk.call.send(*args) end end bar.filter{|i| a = [i.to_i, nil, i]; a[1] = Foo.new{a[1] = a[2].to_s}; a }.sort!.filter{|i| i.pop } --- 豊福 toyofuku@juice.or.jp