Skip to content

Instantly share code, notes, and snippets.

@dgrahn
Last active December 28, 2015 10:49
Show Gist options
  • Save dgrahn/7488520 to your computer and use it in GitHub Desktop.
Save dgrahn/7488520 to your computer and use it in GitHub Desktop.
My favorite Ruby Core Extensions.
class Object
# Check to see if a the object exists within an array. This is a reflexion of
# {Array#include?} to make conditionals more readable.
#
# @param array [Array(Object)] The array to check
#
# @example
# 'Draper'.in? ['Sterling', 'Cooper', 'Draper', 'Pryce']
# # => true
#
# @example
# 'Harris'.in? ['Sterling', 'Cooper', 'Draper', 'Pryce']
# # => false
#
def in?(array)
array.include?(self)
end
end #Object
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment