Skip to content

Instantly share code, notes, and snippets.

@taq
Created April 18, 2013 15:52
Show Gist options
  • Select an option

  • Save taq/5413841 to your computer and use it in GitHub Desktop.

Select an option

Save taq/5413841 to your computer and use it in GitHub Desktop.
Overiding == operator in Ruby.
class Pessoa
attr_accessor :nome
def initialize(nome)
self.nome = nome
end
def ==(outra)
outra == self.nome
end
end
p = Pessoa.new("vinicius")
puts p == "taq"
puts p == "vinicius"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment