if文をずらずら書かないために

rubyだけじゃないんだけど。
変数の値を繰り替えしif文の条件にする場合

1
2
3
if crud == 'insert' || crud == 'update' || crud == 'delete'
  #do somtehing
end

だったらこう書いた方がいいよね。

1
2
3
if ['insert','update','delete'].include?(crud)
  #do somtehing
end

他に良い案ありますか?

Comments