mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-02-16 22:05:35 +01:00
Merge pull request #4428 from adambard/mribeirodantas-update-groovy-pt
Update groovy-pt.html.markdown
This commit is contained in:
commit
2815ed7795
@ -5,7 +5,8 @@ filename: learngroovy-pt.groovy
|
|||||||
contributors:
|
contributors:
|
||||||
- ["Roberto Pérez Alcolea", "http://github.com/rpalcolea"]
|
- ["Roberto Pérez Alcolea", "http://github.com/rpalcolea"]
|
||||||
translators:
|
translators:
|
||||||
- ["João Farias", "https://github.com/JoaoGFarias"]
|
- ["João Farias", "https://github.com/joaogfarias"]
|
||||||
|
- ["Marcel Ribeiro-Dantas", "https://github.com/mribeirodantas"]
|
||||||
lang: pt-br
|
lang: pt-br
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -201,8 +202,16 @@ if(x==1) {
|
|||||||
|
|
||||||
//Groovy também suporta o operador ternário
|
//Groovy também suporta o operador ternário
|
||||||
def y = 10
|
def y = 10
|
||||||
def x = (y > 1) ? "functionou" : "falhou"
|
def x = (y > 1) ? "funcionou" : "falhou"
|
||||||
assert x == "functionou"
|
assert x == "funcionou"
|
||||||
|
|
||||||
|
//E suporta o 'The Elvis Operator' também!
|
||||||
|
//Em vez de usar o operador ternário:
|
||||||
|
|
||||||
|
displayName = nome.name ? nome.name : 'Anonimo'
|
||||||
|
|
||||||
|
//Podemos escrever:
|
||||||
|
displayName = nome.name ?: 'Anonimo'
|
||||||
|
|
||||||
//Loop 'for'
|
//Loop 'for'
|
||||||
//Itera sobre um intervalo (range)
|
//Itera sobre um intervalo (range)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user