以下の内容はhttps://tbpgr.hatenablog.com/entry/20120812/1344787603より取得しました。


自作ユーティリティー | 複数項目のor比較。SQLのinをJavaで再現 をRubyで書いてみた

サンプルコード

# encoding: Windows-31J

class String
  def in(*expects)
    raise "error" if expects[0].nil?
    return !(expects.index(self).nil?)
  end
end

def execute()
  puts "ほげ".in("ひげ")
  puts "ほげ".in("ほげ")
  puts "ほげ".in("はげ","ひげ","ふご")
  puts "ほげ".in("はげ","ほげ","ふご")
  puts "ほげ".in(nil)

  rescue
    puts "ERROR"
end

execute

出力

false
true
false
true
ERROR



以上の内容はhttps://tbpgr.hatenablog.com/entry/20120812/1344787603より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14