Sha256: e30cc8db6ac7d542e147d1ff9ac4d05ef09abcbe84995f719a167c6b15f4a809
Contents?: true
Size: 798 Bytes
Versions: 10
Compression:
Stored size: 798 Bytes
Contents
class Object # Returns true if this object is included in the argument. Argument must be # any object which responds to +#include?+. Usage: # # characters = ["Konata", "Kagami", "Tsukasa"] # "Konata".in?(characters) # => true # # This will throw an ArgumentError if the argument doesn't respond # to +#include?+. def in?(*args) if args.length > 1 puts "Calling #in? with multiple arguments is" \ " deprecated, please pass in an object that responds to #include? instead." args.include? self else another_object = args.first if another_object.respond_to? :include? another_object.include? self else raise ArgumentError.new 'The single parameter passed to #in? must respond to #include?' end end end end
Version data entries
10 entries across 10 versions & 1 rubygems