2006-04-19
          [Ruby]どこまでDRY?
なんかこういうコードがDRYでない気がしてくるのですが。
@maxx = screen.w - @image.w @maxy = screen.h - @image.h @x = rand(@maxx) @y = rand(@maxy) @vx = rand(5) + 5 @vy = rand(5) + 5
じゃあこうするんですか?
[[:x, :w], [:y, :h]].each do |x, w|
  eval "@max#{x} = screen.#{w} - @image.#{w}
       @#{x} = rand(@max#{x})
       @v#{x} = rand(5) + 5"
end
            うーむ。