Alias method name : object Creation « Class « Ruby






Alias method name


class Object

  def in(other)
    other.include? self
  end

end

x = [1, 2, 3]
if 2.in x
  puts "yes"     # Prints "yes"
else
  puts "no"
end

 








Related examples in the same category

1.Creating an Object
2.Add private method to Object and call it in instance class