Iniciando em Scala
-
Upload
diego-gusava -
Category
Software
-
view
106 -
download
0
description
Transcript of Iniciando em Scala
![Page 1: Iniciando em Scala](https://reader035.fdocument.pub/reader035/viewer/2022062304/5594b6d71a28ab8c3d8b472a/html5/thumbnails/1.jpg)
ScalaPara Jovens
![Page 2: Iniciando em Scala](https://reader035.fdocument.pub/reader035/viewer/2022062304/5594b6d71a28ab8c3d8b472a/html5/thumbnails/2.jpg)
Scala
Qual minha principal motivação em aprender Scala?
![Page 3: Iniciando em Scala](https://reader035.fdocument.pub/reader035/viewer/2022062304/5594b6d71a28ab8c3d8b472a/html5/thumbnails/3.jpg)
Quem está usando?
![Page 4: Iniciando em Scala](https://reader035.fdocument.pub/reader035/viewer/2022062304/5594b6d71a28ab8c3d8b472a/html5/thumbnails/4.jpg)
Scala vs Java IDE cuspindo código
Scala S2
![Page 5: Iniciando em Scala](https://reader035.fdocument.pub/reader035/viewer/2022062304/5594b6d71a28ab8c3d8b472a/html5/thumbnails/5.jpg)
Scala vs Java
Roda na JVM
Integra 100% com libs Java
Linguagem Hibrida: OO e Funcional
Tipagem Estática
Tudo é Objeto
![Page 6: Iniciando em Scala](https://reader035.fdocument.pub/reader035/viewer/2022062304/5594b6d71a28ab8c3d8b472a/html5/thumbnails/6.jpg)
Paradigmas
OO Funcional
Composição de Objetos Composição de Funções
Mutabilidade Imutável
Algoritmos Iterativos Algoritmos Recursivos
![Page 7: Iniciando em Scala](https://reader035.fdocument.pub/reader035/viewer/2022062304/5594b6d71a28ab8c3d8b472a/html5/thumbnails/7.jpg)
Básico
Tudo é público por padrão
Inferindo o tipo (String)
Não precisa de vírgula
Variável Mutável
Variável Imutável
Declarando o tipo
![Page 8: Iniciando em Scala](https://reader035.fdocument.pub/reader035/viewer/2022062304/5594b6d71a28ab8c3d8b472a/html5/thumbnails/8.jpg)
EstruturaParâmetros Retorno
Dispensável se retorna Unit
Dispensa return
Obrigatório p/ +1 linha
![Page 9: Iniciando em Scala](https://reader035.fdocument.pub/reader035/viewer/2022062304/5594b6d71a28ab8c3d8b472a/html5/thumbnails/9.jpg)
FunçõesValor
Padrão
Recebo 2 Parâmetros
Retorno
Função padrão utilizada
![Page 10: Iniciando em Scala](https://reader035.fdocument.pub/reader035/viewer/2022062304/5594b6d71a28ab8c3d8b472a/html5/thumbnails/10.jpg)
FunçõesPassando função
por parâmetro Currying
Qualquer coisa
Função Anônima
![Page 11: Iniciando em Scala](https://reader035.fdocument.pub/reader035/viewer/2022062304/5594b6d71a28ab8c3d8b472a/html5/thumbnails/11.jpg)
Classes e ObjetosConstrutor, Propriedades
e tudo final :)
Chamando as propriedadesCompanion
ObjectMinha classe estática
Método Default
![Page 12: Iniciando em Scala](https://reader035.fdocument.pub/reader035/viewer/2022062304/5594b6d71a28ab8c3d8b472a/html5/thumbnails/12.jpg)
Classes e Objetos
Construtor, Propriedades e tudo final :)
equals, hashCode, apply e unnaply
Clone da classe
Definindo os parâmetros
Novo Construtor
Definindo os valores default
Restrições da Classe
Novo Construtor
![Page 13: Iniciando em Scala](https://reader035.fdocument.pub/reader035/viewer/2022062304/5594b6d71a28ab8c3d8b472a/html5/thumbnails/13.jpg)
Pattern Matching
parecido com switch do java
decompõe o objeto
Qualquer coisa
![Page 14: Iniciando em Scala](https://reader035.fdocument.pub/reader035/viewer/2022062304/5594b6d71a28ab8c3d8b472a/html5/thumbnails/14.jpg)
TuplasVocê não precisa criar
classes
O acesso as variáveis
![Page 15: Iniciando em Scala](https://reader035.fdocument.pub/reader035/viewer/2022062304/5594b6d71a28ab8c3d8b472a/html5/thumbnails/15.jpg)
TraitsParecidas com as
Interfaces Java
Podem ter métodos default
Mixing
![Page 16: Iniciando em Scala](https://reader035.fdocument.pub/reader035/viewer/2022062304/5594b6d71a28ab8c3d8b472a/html5/thumbnails/16.jpg)
Coleções
Inicia com um valor definido
Mapeia para outra listagem
Inicia com o primeiro elemento
![Page 17: Iniciando em Scala](https://reader035.fdocument.pub/reader035/viewer/2022062304/5594b6d71a28ab8c3d8b472a/html5/thumbnails/17.jpg)
Nice Features
String InterpolationNullpointerException
nunca mais