独自ハッシュとデータ型判定サンプル
#独自ハッシュとデータ型判定サンプル class MyHash def initialize @inner_hash = Hash.new() end def []=(key,value) if key.is_a?(Integer) == true #データ型判定 @inner_hash[key] = value end end def [](key) return @inner_hash[key] end end obj = MyHash.new() obj["123"] = "一二三" obj[123] = "イチニサン" puts obj["123"] #nil puts obj[123] #イチニサン