Created
May 11, 2018 17:38
-
-
Save douglasmartins7/b726567f76ac7a7ce3ca41534c623e03 to your computer and use it in GitHub Desktop.
Ruby
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# inserir modulos dentro da estancia | |
module Validacoes | |
def validar_cpf | |
true | |
end | |
def validar_cnpj | |
false | |
end | |
end | |
a = "Douglas" | |
a.extended Validacoes | |
############################################### | |
module Teste | |
def oi | |
"ola" | |
end | |
end | |
String.include Teste # eu incluo o modulo Teste direto no objeto String | |
# entao se for chamado qualquer objeto do tipo String ele entedera o metodo oi | |
"sei la".oi #funciona | |
"Dahh".oi #funciona | |
String.extended Teste | |
include eu insiro na estancia | |
extended eu insiro na classe |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment