Last active
December 6, 2017 03:52
-
-
Save henriqueutsch/a113cbda96cd64f4a2af84dcda6bce17 to your computer and use it in GitHub Desktop.
Resumo Geral
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
def nomecompleto(nome,nomemeio,lastname,endereco,telefone) | |
nome = nome.gsub("e","o") | |
nomecompleto = "#{nome} #{nomemeio} #{lastname}" | |
mensagem = "Olá #{nomecompleto} você mora na #{endereco} com telefone #{telefone}" | |
puts mensagem | |
end | |
nomecompleto("Henrique","Avila","Utsch","Av Contorno","(31)9 2222-2222") | |
nomecompleto("Pedro","Drumond","Magalhães","Av Raja","(31)9 3333-3333") | |
coach_answer("ola") | |
# nome = "Henrique" | |
# nomemeio = "Avila" | |
# ultimonome = "Utsch" | |
# endereco = "Avenida contorno" | |
# telefone = "(31)9 2222-2222" |
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
nome = "Henrique" | |
endereço = "Avenida contorno" | |
idade = "30" | |
String "Henrique" 'Henrique' | |
Float 10.345234523452345 | |
Integer (Fixnum) 10 | |
Boolean True False teste = true | |
conjunto = ["teste",10,true,10.5] | |
aluno = ["maria","joao","augusto"] | |
nota = [10,20,30] | |
aluno[0] nota[0] |
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
def Imprimenome(first_name, last_name = nil) | |
if first_name.class? Fixnum | |
nome = "[Nome com número]" | |
else | |
nome = first_name.gsub("e","a").upcase | |
end | |
sobrenome = last_name.upcase | |
nomecomum = "Meu nome completo é: #{nome} #{sobrenome}" | |
inverte = "Meu nome completo é: #{nome} #{sobrenome}".reverse | |
return nomecomum + inverte | |
# return nome + sobrenome | |
end | |
# puts Imprimenome(1234567,"1234567") | |
puts Imprimenome("Henrique","Utsch") | |
# p Imprimenome("MariaH","joaquina") | |
# p Imprimenome("iiiiiiiii","aaaaa") |
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
#Podemos usar | |
puts "Imprime algo com puts" | |
puts 'Imprime algo com puts' | |
print "Imprime algo com print" | |
print 'Imprime algo com print' | |
p "Imprime algo com p" | |
p 'Imprime algo com p' | |
#Diferenças | |
puts => adds a new line to the end of each argument if there is not one already. | |
print => does not add a new line. | |
p => It is also important to note that puts "reacts" to a class that has to_s defined, p does not | |
#aspas | |
'' => imprime caracter especial ''.;/[az10' | |
"" => imprime texto e variaveis "Aqui podemos imprimir uma #{variável}" |
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
https://www.tutorialspoint.com/ruby/ruby_variables.htm | |
https://stackoverflow.com/questions/1255324/p-vs-puts-in-ruby | |
https://stackoverflow.com/questions/5018633/what-is-the-difference-between-print-and-puts | |
http://www.garethrees.co.uk/2013/05/04/p-vs-puts-vs-print-in-ruby/ | |
https://pt.stackoverflow.com/questions/210705/puts-e-p-em-ruby | |
https://www.caelum.com.br/apostila-ruby-on-rails/mais-ruby-classes-objetos-e-metodos/#4-3-definicao-de-metodos | |
https://www.skorks.com/2009/08/method-arguments-in-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
def é uma palavra chave do Ruby para a definição (criação) de métodos, que podem, claro, receber parâmetros: | |
def pessoa.vai(lugar) | |
puts "indo para " + lugar | |
end |
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
String | |
#Nomes ou letras, sem entre aspas simples ou duplas | |
"Henrique" | |
'Henrique' | |
name = "Henrique" | |
Float | |
#Número quebrado com casas decimais | |
10.345234523452345 | |
pi = 3.14 | |
Integer (Fixnum) | |
#Número inteiro | |
10 | |
integer = 10 | |
Boolean | |
#Variável do tipo verdadeira ou falsa | |
True | |
False | |
boolean = true | |
Array | |
#É um confunto de dadeos agrupados | |
conjunto = ["teste",10,true,10.5] | |
aluno = ["maria","joao","augusto"] | |
nota = [10,20,30] | |
Variável | |
#Local onde se atribui um valor. | |
variavel = "Alguma String" | |
variavel = 4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment